Puppeteer with proxy
This example demonstrates how to load pages in headless Chrome / Puppeteer over Apify Proxy.
To make it work, you'll need an Apify account with access to the proxy. Visit the Apify platform introduction to find how to log into your account from the SDK.
tip
To run this example on the Apify Platform, select the apify/actor-node-puppeteer-chrome
image for your Dockerfile.
import { Actor } from 'apify';
import { PuppeteerCrawler } from 'crawlee';
await Actor.init();
// Proxy connection is automatically established in the Crawler
const proxyConfiguration = await Actor.createProxyConfiguration();
const crawler = new PuppeteerCrawler({
proxyConfiguration,
async requestHandler({ page }) {
const status = await page.$eval('td.status', (el) => el.textContent);
console.log(`Proxy Status: ${status}`);
},
});
console.log('Running Puppeteer script...');
await crawler.run(['http://proxy.apify.com']);
console.log('Puppeteer closed.');
await Actor.exit();