@crawlee/puppeteer 4.0.0-beta.86 → 4.0.0-beta.87
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.
|
@@ -139,7 +139,10 @@ export class PuppeteerCrawler extends BrowserCrawler {
|
|
|
139
139
|
addInterceptRequestHandler: async (handler) => puppeteerUtils.addInterceptRequestHandler(context.page, handler),
|
|
140
140
|
removeInterceptRequestHandler: async (handler) => puppeteerUtils.removeInterceptRequestHandler(context.page, handler),
|
|
141
141
|
infiniteScroll: async (options) => puppeteerUtils.infiniteScroll(context.page, options),
|
|
142
|
-
saveSnapshot: async (options) => puppeteerUtils.saveSnapshot(context.page, {
|
|
142
|
+
saveSnapshot: async (options) => puppeteerUtils.saveSnapshot(context.page, {
|
|
143
|
+
...options,
|
|
144
|
+
configuration: serviceLocator.getConfiguration(),
|
|
145
|
+
}),
|
|
143
146
|
closeCookieModals: async () => puppeteerUtils.closeCookieModals(context.page),
|
|
144
147
|
};
|
|
145
148
|
}
|
|
@@ -66,7 +66,7 @@ export interface PuppeteerLaunchContext extends BrowserLaunchContext<PuppeteerPl
|
|
|
66
66
|
* @ignore
|
|
67
67
|
*/
|
|
68
68
|
export declare class PuppeteerLauncher extends BrowserLauncher<PuppeteerPlugin, unknown> {
|
|
69
|
-
readonly
|
|
69
|
+
readonly configuration: Configuration;
|
|
70
70
|
protected static optionsShape: {
|
|
71
71
|
// @ts-ignore optional peer dependency or compatibility with es2022
|
|
72
72
|
launcher: import("ow").ObjectPredicate<object> & import("ow").BasePredicate<object | undefined>;
|
|
@@ -90,7 +90,7 @@ export declare class PuppeteerLauncher extends BrowserLauncher<PuppeteerPlugin,
|
|
|
90
90
|
/**
|
|
91
91
|
* All `PuppeteerLauncher` parameters are passed via an launchContext object.
|
|
92
92
|
*/
|
|
93
|
-
constructor(launchContext?: PuppeteerLaunchContext,
|
|
93
|
+
constructor(launchContext?: PuppeteerLaunchContext, configuration?: Configuration);
|
|
94
94
|
protected getDefaultHeadlessOption(): boolean;
|
|
95
95
|
}
|
|
96
96
|
/**
|
|
@@ -121,8 +121,8 @@ export declare class PuppeteerLauncher extends BrowserLauncher<PuppeteerPlugin,
|
|
|
121
121
|
* @param [launchContext]
|
|
122
122
|
* All `PuppeteerLauncher` parameters are passed via an launchContext object.
|
|
123
123
|
* If you want to pass custom `puppeteer.launch(options)` options you can use the `PuppeteerLaunchContext.launchOptions` property.
|
|
124
|
-
* @param [
|
|
124
|
+
* @param [configuration]
|
|
125
125
|
* @returns
|
|
126
126
|
* Promise that resolves to Puppeteer's `Browser` instance.
|
|
127
127
|
*/
|
|
128
|
-
export declare function launchPuppeteer(launchContext?: PuppeteerLaunchContext,
|
|
128
|
+
export declare function launchPuppeteer(launchContext?: PuppeteerLaunchContext, configuration?: Configuration): Promise<Browser>;
|
|
@@ -6,7 +6,7 @@ import ow from 'ow';
|
|
|
6
6
|
* @ignore
|
|
7
7
|
*/
|
|
8
8
|
export class PuppeteerLauncher extends BrowserLauncher {
|
|
9
|
-
|
|
9
|
+
configuration;
|
|
10
10
|
static optionsShape = {
|
|
11
11
|
...BrowserLauncher.optionsShape,
|
|
12
12
|
launcher: ow.optional.object,
|
|
@@ -14,14 +14,14 @@ export class PuppeteerLauncher extends BrowserLauncher {
|
|
|
14
14
|
/**
|
|
15
15
|
* All `PuppeteerLauncher` parameters are passed via an launchContext object.
|
|
16
16
|
*/
|
|
17
|
-
constructor(launchContext = {},
|
|
17
|
+
constructor(launchContext = {}, configuration = Configuration.getGlobalConfiguration()) {
|
|
18
18
|
ow(launchContext, 'PuppeteerLauncher', ow.object.exactShape(PuppeteerLauncher.optionsShape));
|
|
19
19
|
const { launcher = BrowserLauncher.requireLauncherOrThrow('puppeteer', 'apify/actor-node-puppeteer-chrome'), ...browserLauncherOptions } = launchContext;
|
|
20
20
|
super({
|
|
21
21
|
...browserLauncherOptions,
|
|
22
22
|
launcher,
|
|
23
|
-
},
|
|
24
|
-
this.
|
|
23
|
+
}, configuration);
|
|
24
|
+
this.configuration = configuration;
|
|
25
25
|
this.Plugin = PuppeteerPlugin;
|
|
26
26
|
}
|
|
27
27
|
getDefaultHeadlessOption() {
|
|
@@ -57,11 +57,11 @@ export class PuppeteerLauncher extends BrowserLauncher {
|
|
|
57
57
|
* @param [launchContext]
|
|
58
58
|
* All `PuppeteerLauncher` parameters are passed via an launchContext object.
|
|
59
59
|
* If you want to pass custom `puppeteer.launch(options)` options you can use the `PuppeteerLaunchContext.launchOptions` property.
|
|
60
|
-
* @param [
|
|
60
|
+
* @param [configuration]
|
|
61
61
|
* @returns
|
|
62
62
|
* Promise that resolves to Puppeteer's `Browser` instance.
|
|
63
63
|
*/
|
|
64
|
-
export async function launchPuppeteer(launchContext,
|
|
65
|
-
const puppeteerLauncher = new PuppeteerLauncher(launchContext,
|
|
64
|
+
export async function launchPuppeteer(launchContext, configuration = Configuration.getGlobalConfiguration()) {
|
|
65
|
+
const puppeteerLauncher = new PuppeteerLauncher(launchContext, configuration);
|
|
66
66
|
return puppeteerLauncher.launch();
|
|
67
67
|
}
|
|
@@ -305,9 +305,9 @@ export interface SaveSnapshotOptions {
|
|
|
305
305
|
keyValueStoreName?: string | null;
|
|
306
306
|
/**
|
|
307
307
|
* Configuration of the crawler that will be used to save the snapshot.
|
|
308
|
-
* @default Configuration.
|
|
308
|
+
* @default Configuration.getGlobalConfiguration()
|
|
309
309
|
*/
|
|
310
|
-
|
|
310
|
+
configuration?: Configuration;
|
|
311
311
|
}
|
|
312
312
|
/**
|
|
313
313
|
* Saves a full screenshot and HTML of the current page into a Key-Value store.
|
|
@@ -515,12 +515,12 @@ export async function saveSnapshot(page, options = {}) {
|
|
|
515
515
|
saveScreenshot: ow.optional.boolean,
|
|
516
516
|
saveHtml: ow.optional.boolean,
|
|
517
517
|
keyValueStoreName: ow.optional.string,
|
|
518
|
-
|
|
518
|
+
configuration: ow.optional.object,
|
|
519
519
|
}));
|
|
520
|
-
const { key = 'SNAPSHOT', screenshotQuality = 50, saveScreenshot = true, saveHtml = true, keyValueStoreName,
|
|
520
|
+
const { key = 'SNAPSHOT', screenshotQuality = 50, saveScreenshot = true, saveHtml = true, keyValueStoreName, configuration, } = options;
|
|
521
521
|
try {
|
|
522
522
|
const store = await KeyValueStore.open(keyValueStoreName ? { name: keyValueStoreName } : null, {
|
|
523
|
-
|
|
523
|
+
configuration: configuration ?? Configuration.getGlobalConfiguration(),
|
|
524
524
|
});
|
|
525
525
|
if (saveScreenshot) {
|
|
526
526
|
const screenshotName = `${key}.jpg`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crawlee/puppeteer",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.87",
|
|
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": ">=22.0.0"
|
|
@@ -48,11 +48,11 @@
|
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"@apify/datastructures": "^2.0.3",
|
|
51
|
-
"@crawlee/browser": "4.0.0-beta.
|
|
52
|
-
"@crawlee/browser-pool": "4.0.0-beta.
|
|
53
|
-
"@crawlee/core": "4.0.0-beta.
|
|
54
|
-
"@crawlee/types": "4.0.0-beta.
|
|
55
|
-
"@crawlee/utils": "4.0.0-beta.
|
|
51
|
+
"@crawlee/browser": "4.0.0-beta.87",
|
|
52
|
+
"@crawlee/browser-pool": "4.0.0-beta.87",
|
|
53
|
+
"@crawlee/core": "4.0.0-beta.87",
|
|
54
|
+
"@crawlee/types": "4.0.0-beta.87",
|
|
55
|
+
"@crawlee/utils": "4.0.0-beta.87",
|
|
56
56
|
"cheerio": "^1.0.0",
|
|
57
57
|
"devtools-protocol": "*",
|
|
58
58
|
"idcac-playwright": "^0.2.0",
|
|
@@ -79,5 +79,5 @@
|
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
},
|
|
82
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "1b7604cd77b694460aac4448b4555444fa1b2bdb"
|
|
83
83
|
}
|