Skip to content

Is it possible to update the crawler config after initilization? #2533

Answered by barjin
harshmaur asked this question in Q&A
Discussion options

You must be logged in to vote

You can work around this by having multiple ProxyConfiguration objects and pass the newUrlFunction calls to them:

const oneProxyList = new ProxyConfiguration({
    proxyUrls: ['http://proxy1.com', 'http://proxy2.com'],
});

const anotherProxyList = new ProxyConfiguration({
    proxyUrls: ['http://proxy4.com', 'http://proxy5.com'],
});

const crawler = new PlaywrightCrawler({
    proxyConfiguration: new ProxyConfiguration({
        newUrlFunction: async (sessionId, options) => {
            switch (options?.request?.url) {
                case 'http://crawlee.dev':
                    return await oneProxyList.newUrl(sessionId) ?? null;
                case 'http://another.domain':
       …

Replies: 6 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@harshmaur
Comment options

Answer selected by harshmaur
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants