Rotate country in proxy for each request
# crawlee-js
t
can we rotate country for proxy without relaunching crawlee? I need to use specific country for every url, without relaunching crawlee everytime.
a
message has been deleted
l
Yeah, you can do something like this
Copy code
const crawler = new CheerioCrawler(
    {
        proxyConfiguration: await Actor.createProxyConfiguration({ groups: ['RESIDENTIAL'], countryCode: 'US' }),
        requestHandler: async ({ proxyInfo }) => { log.info(proxyInfo?.url ?? ''); },
        preNavigationHooks: [
            async (context) => {
                context.proxyInfo = await (await Actor.createProxyConfiguration({
                    groups: ['RESIDENTIAL'],
                    countryCode: 'IT',
                }))?.newProxyInfo();
            },
        ],
    },
);
t
Thanks man. I would check it out