@crawlee/playwright 3.0.4-beta.8 â 3.0.4-beta.9
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.
- package/README.md +68 -99
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
</picture>
|
|
7
7
|
</a>
|
|
8
8
|
<br>
|
|
9
|
-
<small>The
|
|
9
|
+
<small>The web scraping and browser automation library</small>
|
|
10
10
|
</h1>
|
|
11
11
|
|
|
12
12
|
<p align=center>
|
|
@@ -16,138 +16,107 @@
|
|
|
16
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
17
|
</p>
|
|
18
18
|
|
|
19
|
-
|
|
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. âšī¸
|
|
20
20
|
|
|
21
|
-
Crawlee
|
|
21
|
+
Crawlee covers your crawling and scraping end-to-end and **helps you build reliable scrapers. Fast.**
|
|
22
22
|
|
|
23
|
-
|
|
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.
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
Crawlee is available as the [`crawlee`](https://www.npmjs.com/package/crawlee) NPM package.
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
> đ **View full documentation, guides and examples on the [Crawlee project website](https://crawlee.dev)** đ
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
## Installation
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
- Run your scraping code on a list of 100k URLs in a CSV file, without losing any data when your code crashes.
|
|
33
|
-
- Rotate proxies to hide your browser origin and keep user-like sessions.
|
|
34
|
-
- Disable browser fingerprinting protections used by websites.
|
|
31
|
+
We recommend visiting the [Introduction tutorial](https://crawlee.dev/docs/introduction) in Crawlee documentation for more information.
|
|
35
32
|
|
|
36
|
-
|
|
33
|
+
> Crawlee requires **Node.js 16 or higher**.
|
|
37
34
|
|
|
38
|
-
|
|
35
|
+
### With Crawlee CLI
|
|
39
36
|
|
|
40
|
-
|
|
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.
|
|
41
38
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
- [`PuppeteerCrawler`](https://crawlee.dev/api/puppeteer-crawler/class/PuppeteerCrawler) - Enables the parallel crawling of a large number of web pages using the headless Chrome browser and [Puppeteer](https://github.com/puppeteer/puppeteer). The pool of Chrome browsers is automatically scaled up and down based on available system resources. Available also under `@crawlee/puppeteer` package.
|
|
47
|
-
|
|
48
|
-
- [`PlaywrightCrawler`](https://crawlee.dev/api/playwright-crawler/class/PlaywrightCrawler) - Unlike `PuppeteerCrawler` you can use [Playwright](https://github.com/microsoft/playwright) to manage almost any headless browser. It also provides a cleaner and more mature interface while keeping the ease of use and advanced features. Available also under `@crawlee/playwright` package.
|
|
49
|
-
|
|
50
|
-
- [`BasicCrawler`](https://crawlee.dev/api/basic-crawler/class/BasicCrawler) - Provides a simple framework for the parallel crawling of web pages whose URLs are fed either from a static list or from a dynamic queue of URLs. This class serves as a base for the more specialized crawlers above. Available also under `@crawlee/basic` package.
|
|
51
|
-
|
|
52
|
-
- [`RequestList`](https://crawlee.dev/api/core/class/RequestList) - Represents a list of URLs to crawl. The URLs can be passed in code or in a text file hosted on the web. The list persists its state so that crawling can resume when the Node.js process restarts. Available also under `@crawlee/core` package.
|
|
53
|
-
|
|
54
|
-
- [`RequestQueue`](https://crawlee.dev/api/core/class/RequestQueue) - Represents a queue of URLs to crawl, which is stored either in memory, on a local filesystem, or in the [Apify Cloud](https://apify.com). The queue is used for deep crawling of websites, where you start with several URLs and then recursively follow links to other pages. The data structure supports both breadth-first and depth-first crawling orders. Available also under `@crawlee/core` package.
|
|
55
|
-
|
|
56
|
-
- [`Dataset`](https://crawlee.dev/api/core/class/Dataset) - Provides a store for structured data and enables their export to formats like JSON, JSONL, CSV, XML, Excel or HTML. The data is stored on a local filesystem or in the Apify Cloud. Datasets are useful for storing and sharing large tabular crawling results, such as a list of products or real estate offers. Available also under `@crawlee/core` package.
|
|
57
|
-
|
|
58
|
-
- [`KeyValueStore`](https://crawlee.dev/api/core/class/KeyValueStore) - A simple key-value store for arbitrary data records or files, along with their MIME content type. It is ideal for saving screenshots of web pages, PDFs or to persist the state of your crawlers. The data is stored on a local filesystem or in the Apify Cloud. Available also under `@crawlee/core` package.
|
|
59
|
-
|
|
60
|
-
- [`AutoscaledPool`](https://crawlee.dev/api/core/class/AutoscaledPool) - Runs asynchronous background tasks, while automatically adjusting the concurrency based on free system memory and CPU usage. This is useful for running web scraping tasks at the maximum capacity of the system. Available also under `@crawlee/core` package.
|
|
61
|
-
|
|
62
|
-
Additionally, the package provides various helper functions to simplify running your code on the Apify Cloud and thus take advantage of its pool of proxies, job scheduler, data storage, etc. For more information, see the [Crawlee Programmer's Reference](https://crawlee.dev).
|
|
63
|
-
|
|
64
|
-
## Quick Start
|
|
65
|
-
|
|
66
|
-
This short tutorial will set you up to start using Crawlee in a minute or two. If you want to learn more, proceed to the [Getting Started](https://crawlee.dev/docs/introduction) tutorial that will take you step by step through creating your first scraper.
|
|
39
|
+
```bash
|
|
40
|
+
npx crawlee create my-crawler
|
|
41
|
+
```
|
|
67
42
|
|
|
68
|
-
|
|
43
|
+
```bash
|
|
44
|
+
cd my-crawler
|
|
45
|
+
npm start
|
|
46
|
+
```
|
|
69
47
|
|
|
70
|
-
|
|
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.
|
|
71
50
|
|
|
72
51
|
```bash
|
|
73
52
|
npm install crawlee playwright
|
|
74
53
|
```
|
|
75
54
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
Run the following example to perform a recursive crawl of a website using Playwright. For more examples showcasing various features of Crawlee, [see the Examples section of the documentation](https://crawlee.dev/docs/examples/crawl-multiple-urls).
|
|
79
|
-
|
|
80
|
-
```javascript
|
|
55
|
+
```js
|
|
81
56
|
import { PlaywrightCrawler, Dataset } from 'crawlee';
|
|
82
57
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
crawler
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
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();
|
|
72
|
+
},
|
|
73
|
+
// Uncomment this option to see the browser window.
|
|
74
|
+
// headless: false,
|
|
94
75
|
});
|
|
95
76
|
|
|
96
|
-
|
|
77
|
+
// Add first URL to the queue and start the crawl.
|
|
78
|
+
await crawler.run(['https://crawlee.dev']);
|
|
97
79
|
```
|
|
98
80
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-

|
|
102
|
-
|
|
103
|
-
By default, Crawlee stores data to `./storage` in the current working directory. You can override this directory via `CRAWLEE_STORAGE_DIR` env var. For details, see [Environment variables](https://crawlee.dev/docs/guides/environment-variables), [Request storage](https://crawlee.dev/docs/guides/request-storage) and [Result storage](https://crawlee.dev/docs/guides/result-storage).
|
|
104
|
-
|
|
105
|
-
### Local usage with Crawlee command-line interface (CLI)
|
|
106
|
-
|
|
107
|
-
To create a boilerplate of your project we can use the [Crawlee command-line interface (CLI)](https://github.com/apify/apify-cli) tool.
|
|
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).
|
|
108
82
|
|
|
109
|
-
|
|
83
|
+
## đ Features
|
|
110
84
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
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
|
|
116
95
|
|
|
117
|
-
|
|
118
|
-
cd my-hello-world
|
|
119
|
-
npx crawlee run
|
|
120
|
-
```
|
|
96
|
+
### đž HTTP crawling
|
|
121
97
|
|
|
122
|
-
|
|
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
|
|
123
103
|
|
|
124
|
-
###
|
|
125
|
-
|
|
126
|
-
Now if we want to run our new crawler on Apify Platform, we first need to download the `apify-cli` and login with our token:
|
|
127
|
-
|
|
128
|
-
> We could also use the Apify CLI to generate a new project, which can be better suited if we want to run it on the Apify Platform.
|
|
129
|
-
|
|
130
|
-
```bash
|
|
131
|
-
npm i -g apify-cli
|
|
132
|
-
apify login
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
Finally, we can easily deploy our code to the Apify platform by running:
|
|
136
|
-
|
|
137
|
-
```bash
|
|
138
|
-
apify push
|
|
139
|
-
```
|
|
104
|
+
### đģ Real browser crawling
|
|
140
105
|
|
|
141
|
-
|
|
142
|
-
|
|
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
|
|
143
112
|
|
|
144
|
-
|
|
113
|
+
## Usage on the Apify platform
|
|
145
114
|
|
|
146
|
-
|
|
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.
|
|
147
116
|
|
|
148
117
|
## Support
|
|
149
118
|
|
|
150
|
-
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) or
|
|
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).
|
|
151
120
|
|
|
152
121
|
## Contributing
|
|
153
122
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crawlee/playwright",
|
|
3
|
-
"version": "3.0.4-beta.
|
|
3
|
+
"version": "3.0.4-beta.9",
|
|
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"
|
|
@@ -55,10 +55,10 @@
|
|
|
55
55
|
"dependencies": {
|
|
56
56
|
"@apify/log": "^2.0.0",
|
|
57
57
|
"@apify/datastructures": "^2.0.0",
|
|
58
|
-
"@crawlee/browser": "^3.0.4-beta.
|
|
59
|
-
"@crawlee/browser-pool": "^3.0.4-beta.
|
|
60
|
-
"@crawlee/core": "^3.0.4-beta.
|
|
61
|
-
"@crawlee/utils": "^3.0.4-beta.
|
|
58
|
+
"@crawlee/browser": "^3.0.4-beta.9",
|
|
59
|
+
"@crawlee/browser-pool": "^3.0.4-beta.9",
|
|
60
|
+
"@crawlee/core": "^3.0.4-beta.9",
|
|
61
|
+
"@crawlee/utils": "^3.0.4-beta.9",
|
|
62
62
|
"cheerio": "1.0.0-rc.12",
|
|
63
63
|
"jquery": "^3.6.0",
|
|
64
64
|
"ow": "^0.28.1"
|