Skip to content

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.

Update example_puppeteer_crawler.js

Marek Trunkát344a4d0232ba
diff --git a/examples/example_puppeteer_crawler.js b/examples/example_puppeteer_crawler.js
index 011efcf40..406b08bed 100644
--- a/examples/example_puppeteer_crawler.js
+++ b/examples/example_puppeteer_crawler.js
@@ -19,14 +19,26 @@ Apify.main(async () => {
// If request failes then it's retried 3 times.
// Parameter page is Puppeteers page object with loaded page.
handlePageFunction: async ({ page, request }) => {
- const title = await page.title();
+ const pageTitle = await page.title();
- console.log(`Request ${request.url} succeeded and it's title is ${title}`);
+ console.log(`Request ${request.url} succeeded and it's title is ${pageTitle}`);
+
+ await Apify.pushData({
+ url: request.url,
+ pageTitle,
+ errors: null,
+ })
},
// If request failed 4 times then this function is executed.
handleFailedRequestFunction: async ({ request }) => {
console.log(`Request ${request.url} failed 4 times`);
+
+ await Apify.pushData({
+ url: request.url,
+ pageTitle: null,
+ errors: request.errorMessages,
+ })
},
});