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
docs: misc outdated/broken example scripts (#2079)
Jindřich Bärd0be3053434b
diff --git a/docs/examples/export_entire_dataset.mdx b/docs/examples/export_entire_dataset.mdxindex 633d34045..bea044b92 100644--- a/docs/examples/export_entire_dataset.mdx+++ b/docs/examples/export_entire_dataset.mdx@@ -7,7 +7,7 @@ import RunnableCodeBlock from '@site/src/components/RunnableCodeBlock';import ApiLink from '@site/src/components/ApiLink';import CrawlSource from '!!raw-loader!roa-loader!./export_entire_dataset.ts';-This `Dataset` example uses the `exportToValue` function to export the entire default dataset to a single CSV file into a key-value store named "my-data".+This `Dataset` example uses the `exportToValue` function to export the entire default dataset to a single CSV file into the default key-value store.<RunnableCodeBlock className="language-js" type="cheerio">{CrawlSource}diff --git a/docs/examples/export_entire_dataset.ts b/docs/examples/export_entire_dataset.tsindex fc43eba98..c912a9e5c 100644--- a/docs/examples/export_entire_dataset.ts+++ b/docs/examples/export_entire_dataset.ts@@ -16,5 +16,5 @@ const data = [await Dataset.pushData(data);// Export the entirety of the dataset to a single file in-// a key-value store named "my-data" under the key "OUTPUT"-await Dataset.exportToCSV('OUTPUT', { toKVS: 'my-data' });+// the default key-value store under the key "OUTPUT"+await Dataset.exportToCSV('OUTPUT');diff --git a/docs/examples/forms.ts b/docs/examples/forms.tsindex c311857fa..29677f91d 100644--- a/docs/examples/forms.ts+++ b/docs/examples/forms.ts@@ -18,15 +18,17 @@ await page.select('select#search_language', 'JavaScript');// Submit the form and wait for full load of next pageconsole.log('Submit search form');await Promise.all([- page.waitForNavigation(),+ page.waitForNavigation({ waitUntil: 'networkidle2' }),page.click('#adv_code_search button[type="submit"]'),]);// Obtain and print list of search results-const results = await page.$$eval('div.f4.text-normal a', (nodes) => nodes.map((node) => ({- url: node.href,- name: node.innerText,-})));+const results = await page.$$eval('[data-testid="results-list"] div.search-title > a',+ (nodes) => nodes.map((node) => ({+ url: node.href,+ name: node.innerText,+ })),+);console.log('Results:', results);diff --git a/docs/examples/map.ts b/docs/examples/map.tsindex 67d67d7f0..a06142a91 100644--- a/docs/examples/map.ts+++ b/docs/examples/map.ts@@ -1,9 +1,28 @@import { Dataset, KeyValueStore } from 'crawlee';-const dataset = await Dataset.open<{ headingCount: number }>();+const dataset = await Dataset.open<{+ url: string,+ headingCount: number,+}>();-// calling map function and filtering through mapped items+// Seeding the dataset with some data+await dataset.pushData([+ {+ url: 'https://crawlee.dev/',+ headingCount: 11,+ },+ {+ url: 'https://crawlee.dev/storage',+ headingCount: 8,+ },+ {+ url: 'https://crawlee.dev/proxy',+ headingCount: 4,+ },+]);++// Calling map function and filtering through mapped items...const moreThan5headers = (await dataset.map((item) => item.headingCount)).filter((count) => count > 5);-// saving result of map to default Key-value store+// Saving the result of map to default key-value store...await KeyValueStore.setValue('pages_with_more_than_5_headers', moreThan5headers);diff --git a/docs/examples/reduce.ts b/docs/examples/reduce.tsindex 106d80d2b..243966c90 100644--- a/docs/examples/reduce.ts+++ b/docs/examples/reduce.ts@@ -1,6 +1,25 @@import { Dataset, KeyValueStore } from 'crawlee';-const dataset = await Dataset.open();+const dataset = await Dataset.open<{+ url: string,+ headingCount: number,+}>();++// Seeding the dataset with some data+await dataset.pushData([+ {+ url: 'https://crawlee.dev/',+ headingCount: 11,+ },+ {+ url: 'https://crawlee.dev/storage',+ headingCount: 8,+ },+ {+ url: 'https://crawlee.dev/proxy',+ headingCount: 4,+ },+]);// calling reduce function and using memo to calculate number of headersconst pagesHeadingCount = await dataset.reduce((memo, value) => {diff --git a/website/versioned_docs/version-3.5/examples/export_entire_dataset.mdx b/website/versioned_docs/version-3.5/examples/export_entire_dataset.mdxindex 633d34045..bea044b92 100644--- a/website/versioned_docs/version-3.5/examples/export_entire_dataset.mdx+++ b/website/versioned_docs/version-3.5/examples/export_entire_dataset.mdx@@ -7,7 +7,7 @@ import RunnableCodeBlock from '@site/src/components/RunnableCodeBlock';import ApiLink from '@site/src/components/ApiLink';import CrawlSource from '!!raw-loader!roa-loader!./export_entire_dataset.ts';-This `Dataset` example uses the `exportToValue` function to export the entire default dataset to a single CSV file into a key-value store named "my-data".+This `Dataset` example uses the `exportToValue` function to export the entire default dataset to a single CSV file into the default key-value store.<RunnableCodeBlock className="language-js" type="cheerio">{CrawlSource}diff --git a/website/versioned_docs/version-3.5/examples/export_entire_dataset.ts b/website/versioned_docs/version-3.5/examples/export_entire_dataset.tsindex fc43eba98..e4818f9e5 100644--- a/website/versioned_docs/version-3.5/examples/export_entire_dataset.ts+++ b/website/versioned_docs/version-3.5/examples/export_entire_dataset.ts@@ -16,5 +16,5 @@ const data = [await Dataset.pushData(data);// Export the entirety of the dataset to a single file in-// a key-value store named "my-data" under the key "OUTPUT"-await Dataset.exportToCSV('OUTPUT', { toKVS: 'my-data' });+// the default key-value store under the key "OUTPUT"+await Dataset.exportToCSV('OUTPUT');\ No newline at end of filediff --git a/website/versioned_docs/version-3.5/examples/forms.ts b/website/versioned_docs/version-3.5/examples/forms.tsindex c311857fa..29677f91d 100644--- a/website/versioned_docs/version-3.5/examples/forms.ts+++ b/website/versioned_docs/version-3.5/examples/forms.ts@@ -18,15 +18,17 @@ await page.select('select#search_language', 'JavaScript');// Submit the form and wait for full load of next pageconsole.log('Submit search form');await Promise.all([- page.waitForNavigation(),+ page.waitForNavigation({ waitUntil: 'networkidle2' }),page.click('#adv_code_search button[type="submit"]'),]);// Obtain and print list of search results-const results = await page.$$eval('div.f4.text-normal a', (nodes) => nodes.map((node) => ({- url: node.href,- name: node.innerText,-})));+const results = await page.$$eval('[data-testid="results-list"] div.search-title > a',+ (nodes) => nodes.map((node) => ({+ url: node.href,+ name: node.innerText,+ })),+);console.log('Results:', results);diff --git a/website/versioned_docs/version-3.5/examples/map.ts b/website/versioned_docs/version-3.5/examples/map.tsindex 67d67d7f0..a06142a91 100644--- a/website/versioned_docs/version-3.5/examples/map.ts+++ b/website/versioned_docs/version-3.5/examples/map.ts@@ -1,9 +1,28 @@import { Dataset, KeyValueStore } from 'crawlee';-const dataset = await Dataset.open<{ headingCount: number }>();+const dataset = await Dataset.open<{+ url: string,+ headingCount: number,+}>();-// calling map function and filtering through mapped items+// Seeding the dataset with some data+await dataset.pushData([+ {+ url: 'https://crawlee.dev/',+ headingCount: 11,+ },+ {+ url: 'https://crawlee.dev/storage',+ headingCount: 8,+ },+ {+ url: 'https://crawlee.dev/proxy',+ headingCount: 4,+ },+]);++// Calling map function and filtering through mapped items...const moreThan5headers = (await dataset.map((item) => item.headingCount)).filter((count) => count > 5);-// saving result of map to default Key-value store+// Saving the result of map to default key-value store...await KeyValueStore.setValue('pages_with_more_than_5_headers', moreThan5headers);diff --git a/website/versioned_docs/version-3.5/examples/reduce.ts b/website/versioned_docs/version-3.5/examples/reduce.tsindex 106d80d2b..243966c90 100644--- a/website/versioned_docs/version-3.5/examples/reduce.ts+++ b/website/versioned_docs/version-3.5/examples/reduce.ts@@ -1,6 +1,25 @@import { Dataset, KeyValueStore } from 'crawlee';-const dataset = await Dataset.open();+const dataset = await Dataset.open<{+ url: string,+ headingCount: number,+}>();++// Seeding the dataset with some data+await dataset.pushData([+ {+ url: 'https://crawlee.dev/',+ headingCount: 11,+ },+ {+ url: 'https://crawlee.dev/storage',+ headingCount: 8,+ },+ {+ url: 'https://crawlee.dev/proxy',+ headingCount: 4,+ },+]);// calling reduce function and using memo to calculate number of headersconst pagesHeadingCount = await dataset.reduce((memo, value) => {