how to use apify proxy for playwright crawler ?

any working demo, couldn't get it working using documentation provided on crawlee.dev
2 Replies
wee-brown
wee-brown3y ago
proxyConfiguration is the same across all types of crawlers, actually its hard to find actor which not using it rather than opposite, please share run otherwise its unclear what is not working, all actors in Store supposed to be proxy-based
metropolitan-bronze
metropolitan-bronze3y ago
In order to use Apify proxy, you'll need to use the ProxyConfiguration class from the apify package instead of the one from the crawlee package. https://sdk.apify.com Here's an example:
import { Actor } from 'apify';
import { PlaywrightCrawler } from 'crawlee';

// create proxyconfiguration with the Apify SDK
const proxyConfiguration = await Actor.createProxyConfiguration({ countryCode: 'US' });

const crawler = new PlaywrightCrawler({
// use this configuration in the Crawlee crawler
proxyConfiguration,
routeHandler: () => {
// ...
},
});
import { Actor } from 'apify';
import { PlaywrightCrawler } from 'crawlee';

// create proxyconfiguration with the Apify SDK
const proxyConfiguration = await Actor.createProxyConfiguration({ countryCode: 'US' });

const crawler = new PlaywrightCrawler({
// use this configuration in the Crawlee crawler
proxyConfiguration,
routeHandler: () => {
// ...
},
});

Did you find this page helpful?