This template is a production ready boilerplate for developing with PuppeteerCrawler
. The PuppeteerCrawler
provides a simple framework for parallel crawling of web pages using headless Chrome with Puppeteer. Since PuppeteerCrawler
uses headless Chrome to download web pages and extract data, it is useful for crawling of websites that require to execute JavaScript.
If you're looking for examples or want to learn more visit:
- Puppeteer Crawler - simple framework for parallel crawling of web pages using headless Chrome with Puppeteer
- Configurable Proxy - tool for working around IP blocking
- Input schema - define and easily validate a schema for your Actor's input
- Dataset - store structured data where each object stored has the same attributes
- Apify SDK - toolkit for building Actors
Actor.getInput()
gets the input fromINPUT.json
where the start urls are defined- Create a configuration for proxy servers to be used during the crawling with
Actor.createProxyConfiguration()
to work around IP blocking. Use Apify Proxy or your own Proxy URLs provided and rotated according to the configuration. You can read more about proxy configuration here. - Create an instance of Crawlee's Puppeteer Crawler with
new PuppeteerCrawler()
. You can pass options to the crawler constructor as:proxyConfiguration
- provide the proxy configuration to the crawlerrequestHandler
- handle each request with custom router defined in theroutes.ts
file.
- Handle requests with the custom router from
routes.ts
file. Read more about custom routing for the Cheerio Crawler here- Create a new router instance with
new createPuppeteerRouter()
- Define default handler that will be called for all URLs that are not handled by other handlers by adding
router.addDefaultHandler(() => { ... })
- Define additional handlers - here you can add your own handling of the page
router.addHandler('detail', async ({ request, page, log }) => { const title = await page.title(); // You can add your own page handling here await Dataset.pushData({ url: request.loadedUrl, title, }); });
- Create a new router instance with
crawler.run(startUrls);
start the crawler and wait for its finish
If you're looking for examples or want to learn more visit:
- Crawlee + Apify Platform guide
- Documentation and examples
- Node.js tutorials in Academy
- How to scale Puppeteer and Playwright
- Video guide on getting data using Apify API
- Integration with Make, GitHub, Zapier, Google Drive, and other apps
- A short guide on how to build web scrapers using code templates: