Crawlee—A web scraping and browser automation library for Node.js to build reliable crawlers. In JavaScript and TypeScript. Extract data for AI, LLMs, RAG, or GPTs. Download HTML, PDF, JPG, PNG, and other files from websites. Works with Puppeteer, Playwright, Cheerio, JSDOM, and raw HTTP. Both headful and headless mode. With proxy rotation.
TypeScript apifyautomationcrawlercrawlingheadlessheadless-chromejavascriptnodejsnpmplaywrightpuppeteerscraperscrapingtypescriptweb-crawlerweb-crawlingweb-scraping
Added examples/puppeteer_sitemap.js
Jan Curn659c767be444
diff --git a/examples/puppeteer_sitemap.js b/examples/puppeteer_sitemap.jsnew file mode 100644index 000000000..9efade374--- /dev/null+++ b/examples/puppeteer_sitemap.js@@ -0,0 +1,30 @@+/**+ * This example demonstrates how to use `PuppeteerCrawler` to crawl a list of web pages+ * specified in a sitemap. The crawler extract page title and URL from each pages+ * and stores it as a record to the default dataset.+ * In local configuration, the results are stored as JSON files in `./apify_storage/datasets/default`+ */++const Apify = require('apify');++Apify.main(async () => {+ const requestList = new Apify.RequestList({+ sources: [{ requestsFromUrl: 'https://edition.cnn.com/sitemaps/cnn/news.xml' }],+ });+ await requestList.initialize();++ const crawler = new Apify.PuppeteerCrawler({+ requestList,+ handlePageFunction: async ({ page, request }) => {+ console.log(`Processing ${request.url}...`);+ await Apify.pushData({+ url: request.url,+ title: await page.title(),+ html: await page.content(),+ });+ },+ });++ await crawler.run();+ console.log('Done.');+});