@crawlee/basic 3.3.4-beta.16 → 3.3.4-beta.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +114 -31
  2. package/package.json +19 -12
package/README.md CHANGED
@@ -1,44 +1,127 @@
1
- # `@crawlee/basic`
1
+ <h1 align="center">
2
+ <a href="https://crawlee.dev">
3
+ <picture>
4
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/apify/crawlee/master/website/static/img/crawlee-dark.svg?sanitize=true">
5
+ <img alt="Crawlee" src="https://raw.githubusercontent.com/apify/crawlee/master/website/static/img/crawlee-light.svg?sanitize=true" width="500">
6
+ </picture>
7
+ </a>
8
+ <br>
9
+ <small>A web scraping and browser automation library</small>
10
+ </h1>
2
11
 
3
- Provides a simple framework for parallel crawling of web pages. The URLs to crawl are fed either from a static list of URLs or from a dynamic queue of URLs enabling recursive crawling of websites.
12
+ <p align=center>
13
+ <a href="https://www.npmjs.com/package/@crawlee/core" rel="nofollow"><img src="https://img.shields.io/npm/v/@crawlee/core.svg" alt="NPM latest version" data-canonical-src="https://img.shields.io/npm/v/@crawlee/core/next.svg" style="max-width: 100%;"></a>
14
+ <a href="https://www.npmjs.com/package/@crawlee/core" rel="nofollow"><img src="https://img.shields.io/npm/dm/@crawlee/core.svg" alt="Downloads" data-canonical-src="https://img.shields.io/npm/dm/@crawlee/core.svg" style="max-width: 100%;"></a>
15
+ <a href="https://discord.gg/jyEM2PRvMU" rel="nofollow"><img src="https://img.shields.io/discord/801163717915574323?label=discord" alt="Chat on discord" data-canonical-src="https://img.shields.io/discord/801163717915574323?label=discord" style="max-width: 100%;"></a>
16
+ <a href="https://github.com/apify/crawlee/actions/workflows/test-and-release.yml"><img src="https://github.com/apify/crawlee/actions/workflows/test-and-release.yml/badge.svg?branch=master" alt="Build Status" style="max-width: 100%;"></a>
17
+ </p>
4
18
 
5
- `BasicCrawler` is a low-level tool that requires the user to implement the page download and data extraction functionality themselves.
6
- If we want a crawler that already facilitates this functionality, we should consider using [CheerioCrawler](https://crawlee.dev/api/cheerio-crawler/class/CheerioCrawler), [PuppeteerCrawler](https://crawlee.dev/api/puppeteer-crawler/class/PuppeteerCrawler) or [PlaywrightCrawler](https://crawlee.dev/api/playwright-crawler/class/PlaywrightCrawler).
19
+ > ℹ️ Crawlee is the successor to [Apify SDK](https://sdk.apify.com). 🎉 Fully rewritten in **TypeScript** for a better developer experience, and with even more powerful anti-blocking features. The interface is almost the same as Apify SDK so upgrading is a breeze. Read [the upgrading guide](https://crawlee.dev/docs/upgrading/upgrading-to-v3) to learn about the changes. ℹ️
7
20
 
8
- `BasicCrawler` invokes the user-provided [`requestHandler`](https://crawlee.dev/api/basic-crawler/interface/BasicCrawlerOptions#requestHandler) for each [Request](https://crawlee.dev/api/core/class/Request) object, which represents a single URL to crawl. The [Request](https://crawlee.dev/api/core/class/Request) objects are fed from the [RequestList](https://crawlee.dev/api/core/class/RequestList) or [RequestQueue](https://crawlee.dev/api/core/class/RequestQueue) instances provided by the [`requestList`](https://crawlee.dev/api/basic-crawler/interface/BasicCrawlerOptions#requestList) or [`requestQueue`](https://crawlee.dev/api/basic-crawler/interface/BasicCrawlerOptions#requestQueue) constructor options, respectively. If neither `requestList` nor `requestQueue` options are provided, the crawler will open the default request queue either when the [`crawler.addRequests()`](https://crawlee.dev/api/basic-crawler/class/BasicCrawler#addRequests) function is called, or if `requests` parameter (representing the initial requests) of the [`crawler.run()`](https://crawlee.dev/api/basic-crawler/class/BasicCrawler#run) function is provided.
21
+ Crawlee covers your crawling and scraping end-to-end and **helps you build reliable scrapers. Fast.**
9
22
 
10
- If both [`requestList`](https://crawlee.dev/api/basic-crawler/interface/BasicCrawlerOptions#requestList) and [`requestQueue`](https://crawlee.dev/api/basic-crawler/interface/BasicCrawlerOptions#requestQueue) options are used, the instance first processes URLs from the [RequestList](https://crawlee.dev/api/core/class/RequestList) and automatically enqueues all of them to the [RequestQueue](https://crawlee.dev/api/core/class/RequestQueue) before it starts their processing. This ensures that a single URL is not crawled multiple times.
23
+ Your crawlers will appear human-like and fly under the radar of modern bot protections even with the default configuration. Crawlee gives you the tools to crawl the web for links, scrape data, and store it to disk or cloud while staying configurable to suit your project's needs.
11
24
 
12
- The crawler finishes if there are no more [Request](https://crawlee.dev/api/core/class/Request) objects to crawl.
25
+ Crawlee is available as the [`crawlee`](https://www.npmjs.com/package/crawlee) NPM package.
13
26
 
14
- New requests are only dispatched when there is enough free CPU and memory available, using the functionality provided by the [AutoscaledPool](https://crawlee.dev/api/core/class/AutoscaledPool) class. All [AutoscaledPool](https://crawlee.dev/api/core/class/AutoscaledPool) configuration options can be passed to the [`autoscaledPoolOptions`](https://crawlee.dev/api/basic-crawler/interface/BasicCrawlerOptions#autoscaledPoolOptions) parameter of the `BasicCrawler` constructor. For user convenience, the [`minConcurrency`](https://crawlee.dev/api/core/interface/AutoscaledPoolOptions#minConcurrency) and [`maxConcurrency`](https://crawlee.dev/api/core/interface/AutoscaledPoolOptions#maxConcurrency) options of the underlying [AutoscaledPool](https://crawlee.dev/api/core/class/AutoscaledPool) constructor are available directly in the `BasicCrawler` constructor.
27
+ > 👉 **View full documentation, guides and examples on the [Crawlee project website](https://crawlee.dev)** 👈
15
28
 
16
- ## Example usage
29
+ ## Installation
17
30
 
18
- ```javascript
19
- import { BasicCrawler, Dataset } from 'crawlee';
31
+ We recommend visiting the [Introduction tutorial](https://crawlee.dev/docs/introduction) in Crawlee documentation for more information.
20
32
 
21
- // Create a crawler instance
22
- const crawler = new BasicCrawler({
23
- async requestHandler({ request, sendRequest }) {
24
- // 'request' contains an instance of the Request class
25
- // Here we simply fetch the HTML of the page and store it to a dataset
26
- const { body } = await sendRequest({
27
- url: request.url,
28
- method: request.method,
29
- body: request.payload,
30
- headers: request.headers,
31
- });
33
+ > Crawlee requires **Node.js 16 or higher**.
32
34
 
33
- await Dataset.pushData({
34
- url: request.url,
35
- html: body,
36
- })
35
+ ### With Crawlee CLI
36
+
37
+ The fastest way to try Crawlee out is to use the **Crawlee CLI** and choose the **Getting started example**. The CLI will install all the necessary dependencies and add boilerplate code for you to play with.
38
+
39
+ ```bash
40
+ npx crawlee create my-crawler
41
+ ```
42
+
43
+ ```bash
44
+ cd my-crawler
45
+ npm start
46
+ ```
47
+
48
+ ### Manual installation
49
+ If you prefer adding Crawlee **into your own project**, try the example below. Because it uses `PlaywrightCrawler` we also need to install [Playwright](https://playwright.dev). It's not bundled with Crawlee to reduce install size.
50
+
51
+ ```bash
52
+ npm install crawlee playwright
53
+ ```
54
+
55
+ ```js
56
+ import { PlaywrightCrawler, Dataset } from 'crawlee';
57
+
58
+ // PlaywrightCrawler crawls the web using a headless
59
+ // browser controlled by the Playwright library.
60
+ const crawler = new PlaywrightCrawler({
61
+ // Use the requestHandler to process each of the crawled pages.
62
+ async requestHandler({ request, page, enqueueLinks, log }) {
63
+ const title = await page.title();
64
+ log.info(`Title of ${request.loadedUrl} is '${title}'`);
65
+
66
+ // Save results as JSON to ./storage/datasets/default
67
+ await Dataset.pushData({ title, url: request.loadedUrl });
68
+
69
+ // Extract links from the current page
70
+ // and add them to the crawling queue.
71
+ await enqueueLinks();
37
72
  },
73
+ // Uncomment this option to see the browser window.
74
+ // headless: false,
38
75
  });
39
76
 
40
- // Enqueue the initial requests and run the crawler
41
- await crawler.run([
42
- 'http://www.example.com/page-1',
43
- 'http://www.example.com/page-2',
44
- ]);
77
+ // Add first URL to the queue and start the crawl.
78
+ await crawler.run(['https://crawlee.dev']);
79
+ ```
80
+
81
+ By default, Crawlee stores data to `./storage` in the current working directory. You can override this directory via Crawlee configuration. For details, see [Configuration guide](https://crawlee.dev/docs/guides/configuration), [Request storage](https://crawlee.dev/docs/guides/request-storage) and [Result storage](https://crawlee.dev/docs/guides/result-storage).
82
+
83
+ ## 🛠 Features
84
+
85
+ - Single interface for **HTTP and headless browser** crawling
86
+ - Persistent **queue** for URLs to crawl (breadth & depth first)
87
+ - Pluggable **storage** of both tabular data and files
88
+ - Automatic **scaling** with available system resources
89
+ - Integrated **proxy rotation** and session management
90
+ - Lifecycles customizable with **hooks**
91
+ - **CLI** to bootstrap your projects
92
+ - Configurable **routing**, **error handling** and **retries**
93
+ - **Dockerfiles** ready to deploy
94
+ - Written in **TypeScript** with generics
95
+
96
+ ### 👾 HTTP crawling
97
+
98
+ - Zero config **HTTP2 support**, even for proxies
99
+ - Automatic generation of **browser-like headers**
100
+ - Replication of browser **TLS fingerprints**
101
+ - Integrated fast **HTML parsers**. Cheerio and JSDOM
102
+ - Yes, you can scrape **JSON APIs** as well
103
+
104
+ ### 💻 Real browser crawling
105
+
106
+ - JavaScript **rendering** and **screenshots**
107
+ - **Headless** and **headful** support
108
+ - Zero-config generation of **human-like fingerprints**
109
+ - Automatic **browser management**
110
+ - Use **Playwright** and **Puppeteer** with the same interface
111
+ - **Chrome**, **Firefox**, **Webkit** and many others
112
+
113
+ ## Usage on the Apify platform
114
+
115
+ Crawlee is open-source and runs anywhere, but since it's developed by [Apify](https://apify.com), it's easy to set up on the Apify platform and run in the cloud. Visit the [Apify SDK website](https://sdk.apify.com) to learn more about deploying Crawlee to the Apify platform.
116
+
117
+ ## Support
118
+
119
+ If you find any bug or issue with Crawlee, please [submit an issue on GitHub](https://github.com/apify/crawlee/issues). For questions, you can ask on [Stack Overflow](https://stackoverflow.com/questions/tagged/apify), in GitHub Discussions or you can join our [Discord server](https://discord.com/invite/jyEM2PRvMU).
120
+
121
+ ## Contributing
122
+
123
+ Your code contributions are welcome, and you'll be praised to eternity! If you have any ideas for improvements, either submit an issue or create a pull request. For contribution guidelines and the code of conduct, see [CONTRIBUTING.md](https://github.com/apify/crawlee/blob/master/CONTRIBUTING.md).
124
+
125
+ ## License
126
+
127
+ This project is licensed under the Apache License 2.0 - see the [LICENSE.md](https://github.com/apify/crawlee/blob/master/LICENSE.md) file for details.
package/package.json CHANGED
@@ -1,18 +1,18 @@
1
1
  {
2
2
  "name": "@crawlee/basic",
3
- "version": "3.3.4-beta.16",
3
+ "version": "3.3.4-beta.17",
4
4
  "description": "The scalable web crawling and scraping library for JavaScript/Node.js. Enables development of data extraction and web automation jobs (not only) with headless Chrome and Puppeteer.",
5
5
  "engines": {
6
6
  "node": ">=16.0.0"
7
7
  },
8
- "main": "./dist/index.js",
9
- "module": "./dist/index.mjs",
10
- "types": "./dist/index.d.ts",
8
+ "main": "./index.js",
9
+ "module": "./index.mjs",
10
+ "types": "./index.d.ts",
11
11
  "exports": {
12
12
  ".": {
13
- "import": "./dist/index.mjs",
14
- "require": "./dist/index.js",
15
- "types": "./dist/index.d.ts"
13
+ "import": "./index.mjs",
14
+ "require": "./index.js",
15
+ "types": "./index.d.ts"
16
16
  },
17
17
  "./package.json": "./package.json"
18
18
  },
@@ -38,7 +38,7 @@
38
38
  "scripts": {
39
39
  "build": "yarn clean && yarn compile && yarn copy",
40
40
  "clean": "rimraf ./dist",
41
- "compile": "tsc -p tsconfig.build.json && gen-esm-wrapper ./dist/index.js ./dist/index.mjs",
41
+ "compile": "tsc -p tsconfig.build.json && gen-esm-wrapper ./index.js ./index.mjs",
42
42
  "copy": "ts-node -T ../../scripts/copy.ts"
43
43
  },
44
44
  "publishConfig": {
@@ -48,13 +48,20 @@
48
48
  "@apify/log": "^2.0.0",
49
49
  "@apify/timeout": "^0.3.0",
50
50
  "@apify/utilities": "^2.0.0",
51
- "@crawlee/core": "^3.3.4-beta.16",
52
- "@crawlee/types": "^3.3.4-beta.16",
53
- "@crawlee/utils": "^3.3.4-beta.16",
51
+ "@crawlee/core": "^3.3.4-beta.17",
52
+ "@crawlee/types": "^3.3.4-beta.17",
53
+ "@crawlee/utils": "^3.3.4-beta.17",
54
54
  "got-scraping": "^3.2.9",
55
55
  "ow": "^0.28.1",
56
56
  "tslib": "^2.4.0",
57
57
  "type-fest": "^3.0.0"
58
58
  },
59
- "gitHead": "67a826c104e2e29a65ff89ccabaecf8b078f2c98"
59
+ "lerna": {
60
+ "command": {
61
+ "publish": {
62
+ "assets": []
63
+ }
64
+ }
65
+ },
66
+ "gitHead": "8bbc596f4dba0aa755df204d836c97c05fc94fca"
60
67
  }