@crawlee/playwright 3.0.0-beta.52 → 3.0.0-beta.55

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 CHANGED
@@ -20,7 +20,7 @@ Crawlee simplifies the development of web crawlers, scrapers, data extractors an
20
20
  It provides tools to manage and automatically scale a pool of headless browsers,
21
21
  to maintain queues of URLs to crawl, store crawling results to a local filesystem or into the cloud,
22
22
  rotate proxies and much more.
23
- The SDK is available as the [`crawlee`](https://www.npmjs.com/package/crawlee) NPM package.
23
+ Crawlee is available as the [`crawlee`](https://www.npmjs.com/package/crawlee) NPM package.
24
24
  It can be used either stand-alone in your own applications
25
25
  or in [actors](https://docs.apify.com/actor)
26
26
  running on the [Apify Cloud](https://apify.com/).
@@ -31,92 +31,59 @@ running on the [Apify Cloud](https://apify.com/).
31
31
 
32
32
  ## Motivation
33
33
 
34
- Thanks to tools like [Playwright](https://github.com/microsoft/playwright), [Puppeteer](https://github.com/puppeteer/puppeteer) or
35
- [Cheerio](https://www.npmjs.com/package/cheerio), it is easy to write Node.js code to extract data from web pages. But
36
- eventually things will get complicated. For example, when you try to:
34
+ Thanks to tools like [Playwright](https://github.com/microsoft/playwright), [Puppeteer](https://github.com/puppeteer/puppeteer) or [Cheerio](https://www.npmjs.com/package/cheerio), it is easy to write Node.js code to extract data from web pages. But eventually things will get complicated. For example, when you try to:
37
35
 
38
36
  - Perform a deep crawl of an entire website using a persistent queue of URLs.
39
37
  - Run your scraping code on a list of 100k URLs in a CSV file, without losing any data when your code crashes.
40
38
  - Rotate proxies to hide your browser origin and keep user-like sessions.
41
39
  - Disable browser fingerprinting protections used by websites.
42
40
 
43
- Python has [Scrapy](https://scrapy.org/) for these tasks, but there was no such library for **JavaScript, the language of
44
- the web**. The use of JavaScript is natural, since the same language is used to write the scripts as well as the data extraction code running in a
45
- browser.
41
+ Python has [Scrapy](https://scrapy.org/) for these tasks, but there was no such library for **JavaScript, the language of the web**. The use of JavaScript is natural, since the same language is used to write the scripts as well as the data extraction code running in a browser.
46
42
 
47
- The goal of Crawlee is to fill this gap and provide a toolbox for generic web scraping, crawling and automation tasks in JavaScript. So don't
48
- reinvent the wheel every time you need data from the web, and focus on writing code specific to the target website, rather than developing
49
- commonalities.
43
+ The goal of Crawlee is to fill this gap and provide a toolbox for generic web scraping, crawling and automation tasks in JavaScript. So don't reinvent the wheel every time you need data from the web, and focus on writing code specific to the target website, rather than developing commonalities.
50
44
 
51
45
  ## Overview
52
46
 
53
47
  Crawlee is available as the [`crawlee`](https://www.npmjs.com/package/crawlee) NPM package and is also available via `@crawlee/*` packages. It provides the following tools:
54
48
 
55
- [//]: # (TODO add links to the docs about `@crawlee/` packages and the `crawlee` metapackage)
49
+ - [`CheerioCrawler`](https://apify.github.io/apify-ts/api/cheerio-crawler/class/CheerioCrawler) - Enables the parallel crawling of a large number of web pages using the [cheerio](https://www.npmjs.com/package/cheerio) HTML parser. This is the most efficient web crawler, but it does not work on websites that require JavaScript. Available also under `@crawlee/cheerio` package.
56
50
 
57
- - [`CheerioCrawler`](https://apify.github.io/apify-ts/api/cheerio-crawler/class/CheerioCrawler) - Enables the parallel crawling of a large
58
- number of web pages using the [cheerio](https://www.npmjs.com/package/cheerio) HTML parser. This is the most
59
- efficient web crawler, but it does not work on websites that require JavaScript.
51
+ - [`PuppeteerCrawler`](https://apify.github.io/apify-ts/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.
60
52
 
61
- - [`PuppeteerCrawler`](https://apify.github.io/apify-ts/api/puppeteer-crawler/class/PuppeteerCrawler) - Enables the parallel crawling of
62
- a large number of web pages using the headless Chrome browser and [Puppeteer](https://github.com/puppeteer/puppeteer).
63
- The pool of Chrome browsers is automatically scaled up and down based on available system resources.
53
+ - [`PlaywrightCrawler`](https://apify.github.io/apify-ts/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.
64
54
 
65
- - [`PlaywrightCrawler`](https://apify.github.io/apify-ts/api/playwright-crawler/class/PlaywrightCrawler) - Unlike `PuppeteerCrawler`
66
- you can use [Playwright](https://github.com/microsoft/playwright) to manage almost any headless browser.
67
- It also provides a cleaner and more mature interface while keeping the ease of use and advanced features.
55
+ - [`BasicCrawler`](https://apify.github.io/apify-ts/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.
68
56
 
69
- - [`BasicCrawler`](https://apify.github.io/apify-ts/api/basic-crawler/class/BasicCrawler) - Provides a simple framework for the parallel
70
- crawling of web pages whose URLs are fed either from a static list or from a dynamic queue of URLs. This class
71
- serves as a base for the more specialized crawlers above.
57
+ - [`RequestList`](https://apify.github.io/apify-ts/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.
72
58
 
73
- - [`RequestList`](https://apify.github.io/apify-ts/api/core/class/RequestList) - Represents a list of URLs to crawl.
74
- The URLs can be passed in code or in a text file hosted on the web. The list persists its state so that crawling
75
- can resume when the Node.js process restarts.
59
+ - [`RequestQueue`](https://apify.github.io/apify-ts/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.
76
60
 
77
- - [`RequestQueue`](https://apify.github.io/apify-ts/api/core/class/RequestQueue) - Represents a queue of URLs to crawl,
78
- which is stored either on a local filesystem or in the [Apify Cloud](https://apify.com). The queue is used
79
- for deep crawling of websites, where you start with several URLs and then recursively follow links to other pages.
80
- The data structure supports both breadth-first and depth-first crawling orders.
61
+ - [`Dataset`](https://apify.github.io/apify-ts/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.
81
62
 
82
- - [`Dataset`](https://apify.github.io/apify-ts/api/core/class/Dataset) - Provides a store for structured data and enables their export
83
- to formats like JSON, JSONL, CSV, XML, Excel or HTML. The data is stored on a local filesystem or in the Apify Cloud.
84
- Datasets are useful for storing and sharing large tabular crawling results, such as a list of products or real estate offers.
63
+ - [`KeyValueStore`](https://apify.github.io/apify-ts/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.
85
64
 
86
- - [`KeyValueStore`](https://apify.github.io/apify-ts/api/core/class/KeyValueStore) - A simple key-value store for arbitrary data
87
- records or files, along with their MIME content type. It is ideal for saving screenshots of web pages, PDFs
88
- or to persist the state of your crawlers. The data is stored on a local filesystem or in the Apify Cloud.
65
+ - [`AutoscaledPool`](https://apify.github.io/apify-ts/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.
89
66
 
90
- - [`AutoscaledPool`](https://apify.github.io/apify-ts/api/core/class/AutoscaledPool) - Runs asynchronous background tasks,
91
- while automatically adjusting the concurrency based on free system memory and CPU usage. This is useful for running
92
- web scraping tasks at the maximum capacity of the system.
93
-
94
- Additionally, the package provides various helper functions to simplify running your code on the Apify Cloud and thus
95
- take advantage of its pool of proxies, job scheduler, data storage, etc.
96
- For more information, see the [Crawlee Programmer's Reference](https://apify.github.io/apify-ts/).
67
+ 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://apify.github.io/apify-ts/).
97
68
 
98
69
  ## Quick Start
99
70
 
100
- This short tutorial will set you up to start using Crawlee in a minute or two.
101
- If you want to learn more, proceed to the [Getting Started](https://apify.github.io/apify-ts/docs/guides/getting-started)
102
- tutorial that will take you step by step through creating your first scraper.
71
+ 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://apify.github.io/apify-ts/docs/guides/getting-started) tutorial that will take you step by step through creating your first scraper.
103
72
 
104
73
  ### Local stand-alone usage
105
74
 
106
- Crawlee requires [Node.js](https://nodejs.org/en/) 16 or later.
107
- Add Crawlee to any Node.js project by running:
75
+ Crawlee requires [Node.js](https://nodejs.org/en/) 16 or later. Add Crawlee to any Node.js project by running:
108
76
 
109
77
  ```bash
110
- npm install @crawlee/playwright playwright
78
+ npm install crawlee playwright
111
79
  ```
112
80
 
113
- > Neither `playwright` nor `puppeteer` are bundled with the SDK to reduce install size and allow greater flexibility. That's why we install it with NPM. You can choose one, both, or neither.
81
+ > Neither `playwright` nor `puppeteer` are bundled with Crawlee to reduce install size and allow greater flexibility. That's why we install it with NPM. You can choose one, both, or neither.
114
82
 
115
- Run the following example to perform a recursive crawl of a website using Playwright. For more examples showcasing various features of Crawlee,
116
- [see the Examples section of the documentation](https://apify.github.io/apify-ts/docs/examples/crawl-multiple-urls).
83
+ 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://apify.github.io/apify-ts/docs/examples/crawl-multiple-urls).
117
84
 
118
85
  ```javascript
119
- import { PlaywrightCrawler } from '@crawlee/playwright';
86
+ import { PlaywrightCrawler } from 'crawlee';
120
87
 
121
88
  const crawler = new PlaywrightCrawler({
122
89
  async requestHandler({ request, page, enqueueLinks }) {
@@ -140,40 +107,38 @@ When you run the example, you should see Crawlee automating a Chrome browser.
140
107
 
141
108
  By default, Crawlee stores data to `./crawlee_storage` in the current working directory. You can override this directory via `CRAWLEE_STORAGE_DIR` env var. For details, see [Environment variables](https://apify.github.io/apify-ts/docs/guides/environment-variables), [Request storage](https://apify.github.io/apify-ts/docs/guides/request-storage) and [Result storage](https://apify.github.io/apify-ts/docs/guides/result-storage).
142
109
 
143
- ### Local usage with Apify command-line interface (CLI)
110
+ ### Local usage with Crawlee command-line interface (CLI)
144
111
 
145
- To avoid the need to set the environment variables manually, to create a boilerplate of your project, and to enable pushing and running your code on
146
- the [Apify platform](https://apify.github.io/apify-ts/docs/guides/apify-platform), you can use the [Apify command-line interface (CLI)](https://github.com/apify/apify-cli) tool.
112
+ To create a boilerplate of your project we can use the [Crawlee command-line interface (CLI)](https://github.com/apify/apify-cli) tool.
147
113
 
148
- Install the CLI by running:
114
+ Let's create a boilerplate of your new web crawling project by running:
149
115
 
150
116
  ```bash
151
- npm -g install apify-cli
117
+ npx crawlee create my-hello-world
152
118
  ```
153
119
 
154
- Now create a boilerplate of your new web crawling project by running:
120
+ The CLI will prompt you to select a project boilerplate template - just pick "Hello world". The tool will create a directory called `my-hello-world` with a Node.js project files. You can run the project as follows:
155
121
 
156
122
  ```bash
157
- apify create my-hello-world
123
+ cd my-hello-world
124
+ npx crawlee run
158
125
  ```
159
126
 
160
- The CLI will prompt you to select a project boilerplate template - just pick "Hello world". The tool will create a directory called `my-hello-world`
161
- with a Node.js project files. You can run the project as follows:
127
+ By default, the crawling data will be stored in a local directory at `./crawlee_storage`. For example, the input JSON file for the actor is expected to be in the default key-value store in `./crawlee_storage/key_value_stores/default/INPUT.json`.
162
128
 
163
- ```bash
164
- cd my-hello-world
165
- apify run
166
- ```
129
+ ### Usage on the Apify platform
167
130
 
168
- By default, the crawling data will be stored in a local directory at `./crawlee_storage`. For example, the input JSON file for the actor is expected to
169
- be in the default key-value store in `./crawlee_storage/key_value_stores/default/INPUT.json`.
131
+ 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:
170
132
 
171
- Now you can easily deploy your code to the Apify platform by running:
133
+ > 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.
172
134
 
173
135
  ```bash
136
+ npm i -g apify-cli
174
137
  apify login
175
138
  ```
176
139
 
140
+ Finally, we can easily deploy our code to the Apify platform by running:
141
+
177
142
  ```bash
178
143
  apify push
179
144
  ```
@@ -181,32 +146,18 @@ apify push
181
146
  Your script will be uploaded to the Apify platform and built there so that it can be run. For more information, view the
182
147
  [Apify Actor](https://docs.apify.com/cli) documentation.
183
148
 
184
- ### Usage on the Apify platform
185
-
186
- You can also develop your web scraping project in an online code editor directly on the [Apify platform](https://apify.github.io/apify-ts/docs/guides/apify-platform).
187
- You'll need to have an Apify Account. Go to [Actors](https://console.apify.com/actors), page in the Apify Console, click <i>Create new</i>
188
- and then go to the <i>Source</i> tab and start writing your code or paste one of the examples from the Examples section.
149
+ You can also develop your web scraping project in an online code editor directly on the [Apify platform](https://apify.github.io/apify-ts/docs/guides/apify-platform). You'll need to have an Apify Account. Go to [Actors](https://console.apify.com/actors), page in the Apify Console, click <i>Create new</i> and then go to the <i>Source</i> tab and start writing your code or paste one of the examples from the Examples section.
189
150
 
190
151
  For more information, view the [Apify actors quick start guide](https://docs.apify.com/actor/quick-start).
191
152
 
192
153
  ## Support
193
154
 
194
- If you find any bug or issue with Crawlee, please [submit an issue on GitHub](https://github.com/apify/apify-js/issues).
195
- For questions, you can ask on [Stack Overflow](https://stackoverflow.com/questions/tagged/apify) or contact support@apify.com
155
+ If you find any bug or issue with Crawlee, please [submit an issue on GitHub](https://github.com/apify/apify-ts/issues). For questions, you can ask on [Stack Overflow](https://stackoverflow.com/questions/tagged/apify) or contact support@apify.com
196
156
 
197
157
  ## Contributing
198
158
 
199
- Your code contributions are welcome and you'll be praised to eternity!
200
- If you have any ideas for improvements, either submit an issue or create a pull request.
201
- For contribution guidelines and the code of conduct,
202
- see [CONTRIBUTING.md](https://github.com/apify/apify-js/blob/master/CONTRIBUTING.md).
159
+ 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/apify-ts/blob/master/CONTRIBUTING.md).
203
160
 
204
161
  ## License
205
162
 
206
- This project is licensed under the Apache License 2.0 -
207
- see the [LICENSE.md](https://github.com/apify/apify-js/blob/master/LICENSE.md) file for details.
208
-
209
- ## Acknowledgments
210
-
211
- Many thanks to [Chema Balsas](https://www.npmjs.com/~jbalsas) for giving up the `apify` package name
212
- on NPM and renaming his project to [jsdocify](https://www.npmjs.com/package/jsdocify).
163
+ This project is licensed under the Apache License 2.0 - see the [LICENSE.md](https://github.com/apify/apify-ts/blob/master/LICENSE.md) file for details.
@@ -2,7 +2,7 @@
2
2
  import type { LaunchOptions, Page, Response } from 'playwright';
3
3
  import type { PlaywrightPlugin } from '@crawlee/browser-pool';
4
4
  import type { BrowserCrawlerOptions, BrowserCrawlingContext, BrowserCrawlerHandleRequest, BrowserHook } from '@crawlee/browser';
5
- import { BrowserCrawler } from '@crawlee/browser';
5
+ import { BrowserCrawler, Configuration } from '@crawlee/browser';
6
6
  import type { Dictionary } from '@crawlee/types';
7
7
  import type { PlaywrightLaunchContext } from './playwright-launcher';
8
8
  import type { DirectNavigationOptions, PlaywrightContextUtils } from './utils/playwright-utils';
@@ -188,6 +188,7 @@ export interface PlaywrightCrawlerOptions extends BrowserCrawlerOptions<Playwrig
188
188
  export declare class PlaywrightCrawler extends BrowserCrawler<{
189
189
  browserPlugins: [PlaywrightPlugin];
190
190
  }, LaunchOptions, PlaywrightCrawlingContext> {
191
+ readonly config: Configuration;
191
192
  protected static optionsShape: {
192
193
  browserPoolOptions: import("ow").ObjectPredicate<object> & import("ow").BasePredicate<object | undefined>;
193
194
  launcher: import("ow").ObjectPredicate<object> & import("ow").BasePredicate<object | undefined>;
@@ -218,7 +219,7 @@ export declare class PlaywrightCrawler extends BrowserCrawler<{
218
219
  /**
219
220
  * All `PlaywrightCrawler` parameters are passed via an options object.
220
221
  */
221
- constructor(options?: PlaywrightCrawlerOptions);
222
+ constructor(options?: PlaywrightCrawlerOptions, config?: Configuration);
222
223
  protected _runRequestHandler(context: PlaywrightCrawlingContext): Promise<void>;
223
224
  protected _navigationHandler(crawlingContext: PlaywrightCrawlingContext, gotoOptions: DirectNavigationOptions): Promise<Response | null>;
224
225
  protected _applyCookies({ session, request, page }: PlaywrightCrawlingContext, preHooksCookies: string, postHooksCookies: string): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"playwright-crawler.d.ts","sourceRoot":"","sources":["../../src/internals/playwright-crawler.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAChE,OAAO,KAAK,EAAsB,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAClF,OAAO,KAAK,EACR,qBAAqB,EACrB,sBAAsB,EACtB,2BAA2B,EAC3B,WAAW,EACd,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACH,cAAc,EAEjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEjD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAErE,OAAO,KAAK,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAGhG,oBAAY,oBAAoB,GAAG,UAAU,CAAC,gBAAgB,CAAC,mBAAmB,CAAC,CAAC,CAAC;AACrF,oBAAY,yBAAyB,CAAC,QAAQ,SAAS,UAAU,GAAG,UAAU,IAC1E,sBAAsB,CAAC,IAAI,EAAE,QAAQ,EAAE,oBAAoB,EAAE,QAAQ,CAAC,GAAG,sBAAsB,CAAC;AACpG,oBAAY,cAAc,GAAG,WAAW,CAAC,yBAAy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,IAAI,EAAE,EAAE,yBAAyB,EAAE,eAAe,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM;CAalJ;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,SAAS,yBAAyB,GAAG,yBAAyB,uDAE3G"}
@@ -72,18 +72,24 @@ class PlaywrightCrawler extends browser_1.BrowserCrawler {
72
72
  /**
73
73
  * All `PlaywrightCrawler` parameters are passed via an options object.
74
74
  */
75
- constructor(options = {}) {
75
+ constructor(options = {}, config = browser_1.Configuration.getGlobalConfig()) {
76
76
  (0, ow_1.default)(options, 'PlaywrightCrawlerOptions', ow_1.default.object.exactShape(PlaywrightCrawler.optionsShape));
77
77
  const { launchContext = {}, browserPoolOptions = {}, ...browserCrawlerOptions } = options;
78
78
  if (launchContext.proxyUrl) {
79
79
  throw new Error('PlaywrightCrawlerOptions.launchContext.proxyUrl is not allowed in PlaywrightCrawler.'
80
80
  + 'Use PlaywrightCrawlerOptions.proxyConfiguration');
81
81
  }
82
- const playwrightLauncher = new playwright_launcher_1.PlaywrightLauncher(launchContext);
82
+ const playwrightLauncher = new playwright_launcher_1.PlaywrightLauncher(launchContext, config);
83
83
  browserPoolOptions.browserPlugins = [
84
84
  playwrightLauncher.createBrowserPlugin(),
85
85
  ];
86
- super({ ...browserCrawlerOptions, browserPoolOptions });
86
+ super({ ...browserCrawlerOptions, browserPoolOptions }, config);
87
+ Object.defineProperty(this, "config", {
88
+ enumerable: true,
89
+ configurable: true,
90
+ writable: true,
91
+ value: config
92
+ });
87
93
  this.launchContext = launchContext;
88
94
  }
89
95
  async _runRequestHandler(context) {
@@ -1 +1 @@
1
- {"version":3,"file":"playwright-crawler.js","sourceRoot":"","sources":["../../src/internals/playwright-crawler.ts"],"names":[],"mappings":";;;;AAAA,oDAAoB;AASpB,8CAG0B;AAE1B,+CAAsC;AAEtC,+DAA2D;AAE3D,+DAAgF;AAgIhF;;;;;;;;;;;;;;;;;;;;;;;;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AAC,IAAI,EAAE,CAAC;QACtE,MAAM,qBAAqB,GAAG,eAAe,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,qBAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,MAAM,EAAkC,CAAC,CAAC;QACnI,MAAM,sBAAsB,GAAG,gBAAgB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,qBAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,MAAM,EAAkC,CAAC,CAAC;QAErI,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC,UAAU,CAC3B;YACI,GAAG,aAAa;YAChB,GAAG,qBAAqB;YACxB,GAAG,sBAAsB;SAC5B,CAAC,MAAM,CAAC,CAAC,CAAC,EAAyB,EAAE,CAAC,CAAC,KAAK,SAAS,CAAC,CAC1D,CAAC;IACN,CAAC;;AAvDL,8CAwDC;AAvDG;;;;WAAyC;QACrC,GAAG,wBAAc,CAAC,YAAY;QAC9B,kBAAkB,EAAE,YAAE,CAAC,QAAQ,CAAC,MAAM;QACtC,QAAQ,EAAE,YAAE,CAAC,QAAQ,CAAC,MAAM;KAC/B;GAAC;AAqDN;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,SAAgB,sBAAsB;IAClC,OAAO,gBAAM,CAAC,MAAM,EAAW,CAAC;AACpC,CAAC;AAFD,wDAEC"}
@@ -2,7 +2,7 @@
2
2
  import type { Browser, BrowserType, LaunchOptions } from 'playwright';
3
3
  import { PlaywrightPlugin } from '@crawlee/browser-pool';
4
4
  import type { BrowserLaunchContext } from '@crawlee/browser';
5
- import { BrowserLauncher } from '@crawlee/browser';
5
+ import { BrowserLauncher, Configuration } from '@crawlee/browser';
6
6
  /**
7
7
  * Apify extends the launch options of Playwright.
8
8
  * You can use any of the Playwright compatible
@@ -38,7 +38,7 @@ export interface PlaywrightLaunchContext extends BrowserLaunchContext<LaunchOpti
38
38
  * If `true` and `executablePath` is not set,
39
39
  * Playwright will launch full Google Chrome browser available on the machine
40
40
  * rather than the bundled Chromium. The path to Chrome executable
41
- * is taken from the `APIFY_CHROME_EXECUTABLE_PATH` environment variable if provided,
41
+ * is taken from the `CRAWLEE_CHROME_EXECUTABLE_PATH` environment variable if provided,
42
42
  * or defaults to the typical Google Chrome executable location specific for the operating system.
43
43
  * By default, this option is `false`.
44
44
  * @default false
@@ -67,6 +67,7 @@ export interface PlaywrightLaunchContext extends BrowserLaunchContext<LaunchOpti
67
67
  * @ignore
68
68
  */
69
69
  export declare class PlaywrightLauncher extends BrowserLauncher<PlaywrightPlugin> {
70
+ readonly config: Configuration;
70
71
  protected static optionsShape: {
71
72
  launcher: import("ow").ObjectPredicate<object> & import("ow").BasePredicate<object | undefined>;
72
73
  proxyUrl: import("ow").StringPredicate & import("ow").BasePredicate<string | undefined>;
@@ -79,7 +80,7 @@ export declare class PlaywrightLauncher extends BrowserLauncher<PlaywrightPlugin
79
80
  /**
80
81
  * All `PlaywrightLauncher` parameters are passed via this launchContext object.
81
82
  */
82
- constructor(launchContext?: PlaywrightLaunchContext);
83
+ constructor(launchContext?: PlaywrightLaunchContext, config?: Configuration);
83
84
  }
84
85
  /**
85
86
  * Launches headless browsers using Playwright pre-configured to work within the Apify platform.
@@ -88,9 +89,9 @@ export declare class PlaywrightLauncher extends BrowserLauncher<PlaywrightPlugin
88
89
  *
89
90
  * The `launchPlaywright()` function alters the following Playwright options:
90
91
  *
91
- * - Passes the setting from the `APIFY_HEADLESS` environment variable to the `headless` option,
92
- * unless it was already defined by the caller or `APIFY_XVFB` environment variable is set to `1`.
93
- * Note that Apify Actor cloud platform automatically sets `APIFY_HEADLESS=1` to all running actors.
92
+ * - Passes the setting from the `CRAWLEE_HEADLESS` environment variable to the `headless` option,
93
+ * unless it was already defined by the caller or `CRAWLEE_XVFB` environment variable is set to `1`.
94
+ * Note that Apify Actor cloud platform automatically sets `CRAWLEE_HEADLESS=1` to all running actors.
94
95
  * - Takes the `proxyUrl` option, validates it and adds it to `launchOptions` in a proper format.
95
96
  * The proxy URL must define a port number and have one of the following schemes: `http://`,
96
97
  * `https://`, `socks4://` or `socks5://`.
@@ -110,8 +111,9 @@ export declare class PlaywrightLauncher extends BrowserLauncher<PlaywrightPlugin
110
111
  * Optional settings passed to `browserType.launch()`. In addition to
111
112
  * [Playwright's options](https://playwright.dev/docs/api/class-browsertype?_highlight=launch#browsertypelaunchoptions)
112
113
  * the object may contain our own {@link PlaywrightLaunchContext} that enable additional features.
114
+ * @param [config]
113
115
  * @returns
114
116
  * Promise that resolves to Playwright's `Browser` instance.
115
117
  */
116
- export declare function launchPlaywright(launchContext?: PlaywrightLaunchContext): Promise<Browser>;
118
+ export declare function launchPlaywright(launchContext?: PlaywrightLaunchContext, config?: Configuration): Promise<Browser>;
117
119
  //# sourceMappingURL=playwright-launcher.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"playwright-launcher.d.ts","sourceRoot":"","sources":["../../src/internals/playwright-launcher.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,WAAW,uBAAwB,SAAQ,oBAAoB,CAAC,aAAa,EAAE,WAAW,CAAC;IAC7F,4GAA4G;IAC5G,aAAa,CAAC,EAAE,aAAa,CAAC;IAE9B;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;;;;;;OAQG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;;;MAIE;IACF,iBAAiB,CAAC,EAAE,OAAO,CAAC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AAgB,CAAC;aAW/C,MAAM;IAV5B,iBAA0B,YAAY;;;;;;;;MAGpC;IAEF;;OAEG;gBAEC,aAAa,GAAE,uBAA4B,EACzB,MAAM,gBAAkC;CAqBjE;AA0BD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAsB,gBAAgB,CAAC,aAAa,CAAC,EAAE,uBAAuB,EAAE,MAAM,gBAAkC,GAAG,OAAO,CAAC,OAAO,CAAC,CAI1I"}
@@ -13,7 +13,7 @@ class PlaywrightLauncher extends browser_1.BrowserLauncher {
13
13
  /**
14
14
  * All `PlaywrightLauncher` parameters are passed via this launchContext object.
15
15
  */
16
- constructor(launchContext = {}) {
16
+ constructor(launchContext = {}, config = browser_1.Configuration.getGlobalConfig()) {
17
17
  (0, ow_1.default)(launchContext, 'PlaywrightLauncherOptions', ow_1.default.object.exactShape(PlaywrightLauncher.optionsShape));
18
18
  const { launcher = browser_1.BrowserLauncher.requireLauncherOrThrow('playwright', 'apify/actor-node-playwright-*').chromium, } = launchContext;
19
19
  const { launchOptions = {}, ...rest } = launchContext;
@@ -21,9 +21,15 @@ class PlaywrightLauncher extends browser_1.BrowserLauncher {
21
21
  ...rest,
22
22
  launchOptions: {
23
23
  ...launchOptions,
24
- executablePath: getDefaultExecutablePath(launchContext),
24
+ executablePath: getDefaultExecutablePath(launchContext, config),
25
25
  },
26
26
  launcher,
27
+ }, config);
28
+ Object.defineProperty(this, "config", {
29
+ enumerable: true,
30
+ configurable: true,
31
+ writable: true,
32
+ value: config
27
33
  });
28
34
  this.Plugin = browser_pool_1.PlaywrightPlugin;
29
35
  }
@@ -39,12 +45,12 @@ Object.defineProperty(PlaywrightLauncher, "optionsShape", {
39
45
  }
40
46
  });
41
47
  /**
42
- * @returns {string | undefined} default path to browser.
43
- * If actor-node-playwright-* image is used the APIFY_DEFAULT_BROWSER_PATH is considered as default.
48
+ * If actor-node-playwright-* image is used the CRAWLEE_DEFAULT_BROWSER_PATH is considered as default.
49
+ * @returns default path to browser.
44
50
  * @ignore
45
51
  */
46
- function getDefaultExecutablePath(launchContext) {
47
- const pathFromPlaywrightImage = process.env.APIFY_DEFAULT_BROWSER_PATH;
52
+ function getDefaultExecutablePath(launchContext, config) {
53
+ const pathFromPlaywrightImage = config.get('defaultBrowserPath');
48
54
  const { launchOptions = {} } = launchContext;
49
55
  if (launchOptions.executablePath) {
50
56
  return launchOptions.executablePath;
@@ -64,9 +70,9 @@ function getDefaultExecutablePath(launchContext) {
64
70
  *
65
71
  * The `launchPlaywright()` function alters the following Playwright options:
66
72
  *
67
- * - Passes the setting from the `APIFY_HEADLESS` environment variable to the `headless` option,
68
- * unless it was already defined by the caller or `APIFY_XVFB` environment variable is set to `1`.
69
- * Note that Apify Actor cloud platform automatically sets `APIFY_HEADLESS=1` to all running actors.
73
+ * - Passes the setting from the `CRAWLEE_HEADLESS` environment variable to the `headless` option,
74
+ * unless it was already defined by the caller or `CRAWLEE_XVFB` environment variable is set to `1`.
75
+ * Note that Apify Actor cloud platform automatically sets `CRAWLEE_HEADLESS=1` to all running actors.
70
76
  * - Takes the `proxyUrl` option, validates it and adds it to `launchOptions` in a proper format.
71
77
  * The proxy URL must define a port number and have one of the following schemes: `http://`,
72
78
  * `https://`, `socks4://` or `socks5://`.
@@ -86,11 +92,12 @@ function getDefaultExecutablePath(launchContext) {
86
92
  * Optional settings passed to `browserType.launch()`. In addition to
87
93
  * [Playwright's options](https://playwright.dev/docs/api/class-browsertype?_highlight=launch#browsertypelaunchoptions)
88
94
  * the object may contain our own {@link PlaywrightLaunchContext} that enable additional features.
95
+ * @param [config]
89
96
  * @returns
90
97
  * Promise that resolves to Playwright's `Browser` instance.
91
98
  */
92
- async function launchPlaywright(launchContext) {
93
- const playwrightLauncher = new PlaywrightLauncher(launchContext);
99
+ async function launchPlaywright(launchContext, config = browser_1.Configuration.getGlobalConfig()) {
100
+ const playwrightLauncher = new PlaywrightLauncher(launchContext, config);
94
101
  return playwrightLauncher.launch();
95
102
  }
96
103
  exports.launchPlaywright = launchPlaywright;
@@ -1 +1 @@
1
- {"version":3,"file":"playwright-launcher.js","sourceRoot":"","sources":["../../src/internals/playwright-launcher.ts"],"names":[],"mappings":";;;;AAAA,oDAAoB;AAEpB,wDAAyD;AAEzD,8CAAmD;AAmEnD;;;GAGG;AACH,MAAa,kBAAmB,SAAQ,yBAAiC;IAMrE;;OAEG;IACH,YAAY,gBAAyC,EAAE;QACnD,IAAA,YAAE,EAAC,aAAa,EAAE,2BAA2B,EAAE,YAAE,CAAC,MAAM,CAAC,UAAU,CAAC,kBAAkB,CAAC,YAAY,CAAC,CAAC,CAAC;QAEtG,MAAM,EACF,QAAQ,GAAG,yBAAe,CAAC,sBAAsB,CAA8B,YAAY,EAAE,+BAA+B,CAAC,CAAC,QAAQ,GACzI,GAAG,aAAa,CAAC;QAElB,MAAM,EAAE,aAAa,GAAG,EAAE,EAAE,GAAG,IAAI,EAAE,GAAG,aAAa,CAAC;QAEtD,KAAK,CAAC;YACF,GAAG,IAAI;YACP,aAAa,EAAE;gBACX,GAAG,aAAa;gBAChB,cAAc,EAAE,wBAAwB,CAAC,aAAa,CAAC;aAC1D;YACD,QAAQ;SACX,CAAC,CAAC;QAEH,IAAI,CAAC,MAAM,GAAG,+BAAgB,CAAC;IACnC,CAAC;;AA5BL,gDA6BC;AA5BG;;;;WAAyC;QACrC,GAAG,yBAAe,CAAC,YAAY;QAC/B,QAAQ,EAAE,YAAE,CAAC,QAAQ,CAAC,MAAM;KAC/B;GAAC;AA2BN;;;;GAIG;AACH,SAAS,wBAAwB,CAAC,aAAsC;IACpE,MAAM,uBAAuB,GAAG,OAAO,CAAC,GAAG,CAAC,0BAA0B,CAAC;IACvE,MAAM,EAAE,aAAa,GAAG,EAAE,EAAE,GAAG,aAAa,CAAC;IAE7C,IAAI,aAAa,CAAC,cAAc,EAAE;QAC9B,OAAO,aAAa,CAAC,cAAc,CAAC;KACvC;IAED,IAAI,aAAa,CAAC,SAAS,EAAE;QACzB,OAAO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YAAY;QAC/B,QAAQ,EAAE,YAAE,CAAC,QAAQ,CAAC,MAAM;KAC/B;GAAC;AA8BN;;;;GAIG;AACH,SAAS,wBAAwB,CAAC,aAAsC,EAAE,MAAqB;IAC3F,MAAM,uBAAuB,GAAG,MAAM,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;IACjE,MAAM,EAAE,aAAa,GAAG,EAAE,EAAE,GAAG,aAAa,CAAC;IAE7C,IAAI,aAAa,CAAC,cAAc,EAAE;QAC9B,OAAO,aAAa,CAAC,cAAc,CAAC;KACvC;IAED,IAAI,aAAa,CAAC,SAAS,EAAE;QACzB,OAAO,SAAS,CAAC;KACpB;IAED,IAAI,uBAAuB,EAAE;QACzB,OAAO,uBAAuB,CAAC;KAClC;IAED,OAAO,SAAS,CAAC;AACrB,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACI,KAAK,UAAU,gBAAgB,CAAC,aAAuC,EAAE,MAAM,GAAG,uBAAa,CAAC,eAAe,EAAE;IACpH,MAAM,kBAAkB,GAAG,IAAI,kBAAkB,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;IAEzE,OAAO,kBAAkB,CAAC,MAAM,EAAE,CAAC;AACvC,CAAC;AAJD,4CAIC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crawlee/playwright",
3
- "version": "3.0.0-beta.52",
3
+ "version": "3.0.0-beta.55",
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.0-beta.52",
59
- "@crawlee/browser-pool": "^3.0.0-beta.52",
60
- "@crawlee/core": "^3.0.0-beta.52",
61
- "@crawlee/utils": "^3.0.0-beta.52",
58
+ "@crawlee/browser": "^3.0.0-beta.55",
59
+ "@crawlee/browser-pool": "^3.0.0-beta.55",
60
+ "@crawlee/core": "^3.0.0-beta.55",
61
+ "@crawlee/utils": "^3.0.0-beta.55",
62
62
  "jquery": "^3.6.0",
63
63
  "ow": "^0.28.1",
64
64
  "tough-cookie": "^4.0.0"