@crawlee/browser 3.0.0-alpha.3 → 3.0.0-alpha.30
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/{dist/README.md → README.md} +0 -0
- package/{dist/index.d.ts → index.d.ts} +0 -0
- package/{dist/index.d.ts.map → index.d.ts.map} +0 -0
- package/{dist/index.js → index.js} +0 -0
- package/{dist/index.js.map → index.js.map} +0 -0
- package/{dist/index.mjs → index.mjs} +1 -4
- package/{dist/internals → internals}/browser-crawler.d.ts +11 -20
- package/internals/browser-crawler.d.ts.map +1 -0
- package/{dist/internals → internals}/browser-crawler.js +48 -59
- package/internals/browser-crawler.js.map +1 -0
- package/{dist/internals → internals}/browser-launcher.d.ts +27 -3
- package/internals/browser-launcher.d.ts.map +1 -0
- package/{dist/internals → internals}/browser-launcher.js +19 -10
- package/internals/browser-launcher.js.map +1 -0
- package/package.json +8 -11
- package/tsconfig.build.tsbuildinfo +1 -0
- package/dist/LICENSE.md +0 -201
- package/dist/internals/browser-crawler.d.ts.map +0 -1
- package/dist/internals/browser-crawler.js.map +0 -1
- package/dist/internals/browser-launcher.d.ts.map +0 -1
- package/dist/internals/browser-launcher.js.map +0 -1
- package/dist/package.json +0 -57
- package/dist/tsconfig.build.tsbuildinfo +0 -1
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -40,7 +40,6 @@ export const Snapshotter = mod.Snapshotter;
|
|
|
40
40
|
export const Statistics = mod.Statistics;
|
|
41
41
|
export const StorageManager = mod.StorageManager;
|
|
42
42
|
export const SystemStatus = mod.SystemStatus;
|
|
43
|
-
export const basicCrawlerEnqueueLinks = mod.basicCrawlerEnqueueLinks;
|
|
44
43
|
export const browserCrawlerEnqueueLinks = mod.browserCrawlerEnqueueLinks;
|
|
45
44
|
export const checkAndSerialize = mod.checkAndSerialize;
|
|
46
45
|
export const chunkBySize = mod.chunkBySize;
|
|
@@ -59,11 +58,9 @@ export const handleRequestTimeout = mod.handleRequestTimeout;
|
|
|
59
58
|
export const log = mod.log;
|
|
60
59
|
export const maybeStringify = mod.maybeStringify;
|
|
61
60
|
export const mergeCookies = mod.mergeCookies;
|
|
62
|
-
export const
|
|
63
|
-
export const pushData = mod.pushData;
|
|
61
|
+
export const resolveBaseUrl = mod.resolveBaseUrl;
|
|
64
62
|
export const serializeArray = mod.serializeArray;
|
|
65
63
|
export const storage = mod.storage;
|
|
66
|
-
export const throwOnBlockedRequest = mod.throwOnBlockedRequest;
|
|
67
64
|
export const updateEnqueueLinksPatternCache = mod.updateEnqueueLinksPatternCache;
|
|
68
65
|
export const validateGlobPattern = mod.validateGlobPattern;
|
|
69
66
|
export const validators = mod.validators;
|
|
@@ -3,7 +3,7 @@ import { BasicCrawler, BasicCrawlerOptions } from '@crawlee/basic';
|
|
|
3
3
|
import { Awaitable, Dictionary } from '@crawlee/utils';
|
|
4
4
|
import { BrowserController, BrowserPlugin, BrowserPool, BrowserPoolHooks, BrowserPoolOptions, CommonPage, InferBrowserPluginArray, LaunchContext } from '@crawlee/browser-pool';
|
|
5
5
|
import { BrowserLaunchContext } from './browser-launcher';
|
|
6
|
-
export interface BrowserCrawlingContext<Page extends CommonPage = CommonPage, Response = Dictionary
|
|
6
|
+
export interface BrowserCrawlingContext<Page extends CommonPage = CommonPage, Response = Dictionary, ProvidedController = BrowserController> extends CrawlingContext {
|
|
7
7
|
browserController: ProvidedController;
|
|
8
8
|
page: Page;
|
|
9
9
|
response?: Response;
|
|
@@ -17,8 +17,8 @@ export declare type BrowserCrawlerHandleFailedRequest = (inputs: BrowserCrawlerH
|
|
|
17
17
|
export declare type BrowserCrawlerHandleRequest<Context extends BrowserCrawlingContext = BrowserCrawlingContext> = (inputs: Context) => Awaitable<void>;
|
|
18
18
|
export declare type BrowserCrawlerEnqueueLinksOptions = Omit<EnqueueLinksOptions, 'requestQueue' | 'urls'>;
|
|
19
19
|
export declare type BrowserHook<Context = BrowserCrawlingContext, GoToOptions extends Record<PropertyKey, any> | undefined = Dictionary> = (crawlingContext: Context, gotoOptions: GoToOptions) => Awaitable<void>;
|
|
20
|
-
export
|
|
21
|
-
|
|
20
|
+
export interface BrowserCrawlerOptions<Context extends BrowserCrawlingContext = BrowserCrawlingContext, InternalBrowserPoolOptions extends BrowserPoolOptions = BrowserPoolOptions, __BrowserPlugins extends BrowserPlugin[] = InferBrowserPluginArray<InternalBrowserPoolOptions['browserPlugins']>, __BrowserControllerReturn extends BrowserController = ReturnType<__BrowserPlugins[number]['createController']>, __LaunchContextReturn extends LaunchContext = ReturnType<__BrowserPlugins[number]['createLaunchContext']>> extends Omit<BasicCrawlerOptions, 'requestHandler' | 'handleRequestFunction' | 'failedRequestHandler' | 'handleFailedRequestFunction'> {
|
|
21
|
+
launchContext?: BrowserLaunchContext<any, any>;
|
|
22
22
|
/**
|
|
23
23
|
* Function that is called to process each request.
|
|
24
24
|
* It is passed an object with the following fields:
|
|
@@ -101,10 +101,6 @@ export interface BrowserCrawlerOptions<Context extends BrowserCrawlingContext =
|
|
|
101
101
|
* @deprecated `handlePageFunction` has been renamed to `requestHandler` and will be removed in a future version.
|
|
102
102
|
*/
|
|
103
103
|
handlePageFunction?: BrowserCrawlerHandleRequest<Context>;
|
|
104
|
-
/**
|
|
105
|
-
* Navigation function for corresponding library. `page.goto(url)` is supported by both `playwright` and `puppeteer`.
|
|
106
|
-
*/
|
|
107
|
-
gotoFunction?: GotoFunction<Context, GoToOptions>;
|
|
108
104
|
/**
|
|
109
105
|
* A function to handle requests that failed more than `option.maxRequestRetries` times.
|
|
110
106
|
*
|
|
@@ -194,10 +190,6 @@ export interface BrowserCrawlerOptions<Context extends BrowserCrawlingContext =
|
|
|
194
190
|
* Timeout in which page navigation needs to finish, in seconds.
|
|
195
191
|
*/
|
|
196
192
|
navigationTimeoutSecs?: number;
|
|
197
|
-
/**
|
|
198
|
-
* @deprecated Use `navigationTimeoutSecs` instead
|
|
199
|
-
*/
|
|
200
|
-
gotoTimeoutSecs?: number;
|
|
201
193
|
/**
|
|
202
194
|
* If cookies should be persisted between sessions.
|
|
203
195
|
* This can only be used when `useSessionPool` is set to `true`.
|
|
@@ -256,18 +248,15 @@ export declare abstract class BrowserCrawler<InternalBrowserPoolOptions extends
|
|
|
256
248
|
launchContext?: BrowserLaunchContext<LaunchOptions, unknown>;
|
|
257
249
|
protected userProvidedRequestHandler: BrowserCrawlerHandleRequest<Context>;
|
|
258
250
|
protected navigationTimeoutMillis: number;
|
|
259
|
-
protected gotoFunction?: GotoFunction<Context, GoToOptions>;
|
|
260
|
-
protected defaultGotoOptions: GoToOptions;
|
|
261
251
|
protected preNavigationHooks: BrowserHook<Context>[];
|
|
262
252
|
protected postNavigationHooks: BrowserHook<Context>[];
|
|
263
253
|
protected persistCookiesPerSession: boolean;
|
|
264
254
|
protected static optionsShape: {
|
|
265
255
|
handlePageFunction: import("ow").Predicate<Function> & import("ow").BasePredicate<Function | undefined>;
|
|
266
|
-
gotoFunction: import("ow").Predicate<Function> & import("ow").BasePredicate<Function | undefined>;
|
|
267
|
-
gotoTimeoutSecs: import("ow").NumberPredicate & import("ow").BasePredicate<number | undefined>;
|
|
268
256
|
navigationTimeoutSecs: import("ow").NumberPredicate & import("ow").BasePredicate<number | undefined>;
|
|
269
257
|
preNavigationHooks: import("ow").ArrayPredicate<unknown> & import("ow").BasePredicate<unknown[] | undefined>;
|
|
270
258
|
postNavigationHooks: import("ow").ArrayPredicate<unknown> & import("ow").BasePredicate<unknown[] | undefined>;
|
|
259
|
+
launchContext: import("ow").ObjectPredicate<object> & import("ow").BasePredicate<object | undefined>;
|
|
271
260
|
browserPoolOptions: import("ow").ObjectPredicate<object>;
|
|
272
261
|
sessionPoolOptions: import("ow").ObjectPredicate<object> & import("ow").BasePredicate<object | undefined>;
|
|
273
262
|
persistCookiesPerSession: import("ow").BooleanPredicate & import("ow").BasePredicate<boolean | undefined>;
|
|
@@ -291,18 +280,19 @@ export declare abstract class BrowserCrawler<InternalBrowserPoolOptions extends
|
|
|
291
280
|
/**
|
|
292
281
|
* All `BrowserCrawler` parameters are passed via an options object.
|
|
293
282
|
*/
|
|
294
|
-
protected constructor(options: BrowserCrawlerOptions<Context
|
|
283
|
+
protected constructor(options: BrowserCrawlerOptions<Context>);
|
|
295
284
|
/**
|
|
296
285
|
* Wrapper around handlePageFunction that opens and closes pages etc.
|
|
297
286
|
*/
|
|
298
287
|
protected _runRequestHandler(crawlingContext: Context): Promise<void>;
|
|
299
288
|
protected _enhanceCrawlingContextWithPageInfo(crawlingContext: Context, page: CommonPage, useIncognitoPages?: boolean): void;
|
|
300
289
|
protected _handleNavigation(crawlingContext: Context): Promise<void>;
|
|
290
|
+
protected _applyCookies({ session, request, page, browserController }: Context, preHooksCookies: string, postHooksCookies: string): Promise<void>;
|
|
301
291
|
/**
|
|
302
292
|
* Marks session bad in case of navigation timeout.
|
|
303
293
|
*/
|
|
304
294
|
protected _handleNavigationTimeout(crawlingContext: Context, error: Error): void;
|
|
305
|
-
protected _navigationHandler(crawlingContext: Context, gotoOptions: GoToOptions): Promise<
|
|
295
|
+
protected abstract _navigationHandler(crawlingContext: Context, gotoOptions: GoToOptions): Promise<Context['response'] | null | undefined>;
|
|
306
296
|
/**
|
|
307
297
|
* Should be overridden in case of different automation library that does not support this response API.
|
|
308
298
|
* @todo: This can be also done as a postNavigation hook except the loadedUrl marking.
|
|
@@ -320,10 +310,11 @@ export declare abstract class BrowserCrawler<InternalBrowserPoolOptions extends
|
|
|
320
310
|
interface EnqueueLinksInternalOptions {
|
|
321
311
|
options?: BrowserCrawlerEnqueueLinksOptions;
|
|
322
312
|
page: CommonPage;
|
|
323
|
-
requestQueue
|
|
324
|
-
|
|
313
|
+
requestQueue: RequestQueue;
|
|
314
|
+
originalRequestUrl: string;
|
|
315
|
+
finalRequestUrl?: string;
|
|
325
316
|
}
|
|
326
317
|
/** @internal */
|
|
327
|
-
export declare function browserCrawlerEnqueueLinks({ options, page, requestQueue,
|
|
318
|
+
export declare function browserCrawlerEnqueueLinks({ options, page, requestQueue, originalRequestUrl, finalRequestUrl, }: EnqueueLinksInternalOptions): Promise<storage.BatchAddRequestsResult>;
|
|
328
319
|
export {};
|
|
329
320
|
//# sourceMappingURL=browser-crawler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser-crawler.d.ts","sourceRoot":"","sources":["../../src/internals/browser-crawler.ts"],"names":[],"mappings":"AACA,OAAO,EACH,mBAAmB,EACnB,+BAA+B,EAC/B,eAAe,EAIf,kBAAkB,EAElB,YAAY,EAGZ,OAAO,EAEV,MAAM,eAAe,CAAC;AACvB,OAAO,EAEH,YAAY,EACZ,mBAAmB,EACtB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAEH,iBAAiB,EACjB,aAAa,EACb,WAAW,EACX,gBAAgB,EAChB,kBAAkB,EAClB,UAAU,EAEV,uBAAuB,EACvB,aAAa,EAChB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE1D,MAAM,WAAW,sBAAsB,CACnC,IAAI,SAAS,UAAU,GAAG,UAAU,EACpC,QAAQ,GAAG,UAAU,EACrB,kBAAkB,GAAG,iBAAiB,CACxC,SAAQ,eAAe;IACrB,iBAAiB,EAAE,kBAAkB,CAAC;IACtC,IAAI,EAAE,IAAI,CAAC;IACX,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,OAAO,EAAE,cAAc,CAAC;IACxB,YAAY,EAAE,CAAC,OAAO,CAAC,EAAE,iCAAiC,KAAK,OAAO,CAAC,OAAO,CAAC,sBAAsB,CAAC,CAAC;CAC1G;AAED,MAAM,WAAW,sCAAuC,SAAQ,+BAA+B;IAC3F,OAAO,EAAE,cAAc,CAAC;CAC3B;AAED,oBAAY,iCAAiC,GAAG,CAAC,MAAM,EAAE,sCAAsC,KAAK,SAAS,CAAC,IAAI,C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ACY,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAI3C;AAED,gBAAgB;AAChB,UAAU,2BAA2B;IACjC,OAAO,CAAC,EAAE,iCAAiC,CAAC;IAC5C,IAAI,EAAE,UAAU,CAAC;IACjB,YAAY,EAAE,YAAY,CAAC;IAC3B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,eAAe,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,gBAAgB;AAChB,wBAAsB,0BAA0B,CAAC,EAC7C,OAAO,EACP,IAAI,EACJ,YAAY,EACZ,kBAAkB,EAClB,eAAe,GAClB,EAAE,2BAA2B,2CAgB7B"}
|
|
@@ -7,6 +7,7 @@ const core_1 = require("@crawlee/core");
|
|
|
7
7
|
const basic_1 = require("@crawlee/basic");
|
|
8
8
|
const browser_pool_1 = require("@crawlee/browser-pool");
|
|
9
9
|
const ow_1 = tslib_1.__importDefault(require("ow"));
|
|
10
|
+
const tough_cookie_1 = require("tough-cookie");
|
|
10
11
|
/**
|
|
11
12
|
* Provides a simple framework for parallel crawling of web pages
|
|
12
13
|
* using headless browsers with [Puppeteer](https://github.com/puppeteer/puppeteer)
|
|
@@ -50,9 +51,7 @@ class BrowserCrawler extends basic_1.BasicCrawler {
|
|
|
50
51
|
*/
|
|
51
52
|
constructor(options) {
|
|
52
53
|
(0, ow_1.default)(options, 'BrowserCrawlerOptions', ow_1.default.object.exactShape(BrowserCrawler.optionsShape));
|
|
53
|
-
const { navigationTimeoutSecs = 60, requestHandlerTimeoutSecs = 60,
|
|
54
|
-
gotoTimeoutSecs, // deprecated
|
|
55
|
-
persistCookiesPerSession, proxyConfiguration, browserPoolOptions, preNavigationHooks = [], postNavigationHooks = [],
|
|
54
|
+
const { navigationTimeoutSecs = 60, requestHandlerTimeoutSecs = 60, persistCookiesPerSession, proxyConfiguration, launchContext, browserPoolOptions, preNavigationHooks = [], postNavigationHooks = [],
|
|
56
55
|
// Ignored
|
|
57
56
|
handleRequestFunction, requestHandler: userProvidedRequestHandler, handlePageFunction, failedRequestHandler, handleFailedRequestFunction, ...basicCrawlerOptions } = options;
|
|
58
57
|
super({
|
|
@@ -99,18 +98,6 @@ class BrowserCrawler extends basic_1.BasicCrawler {
|
|
|
99
98
|
writable: true,
|
|
100
99
|
value: void 0
|
|
101
100
|
});
|
|
102
|
-
Object.defineProperty(this, "gotoFunction", {
|
|
103
|
-
enumerable: true,
|
|
104
|
-
configurable: true,
|
|
105
|
-
writable: true,
|
|
106
|
-
value: void 0
|
|
107
|
-
});
|
|
108
|
-
Object.defineProperty(this, "defaultGotoOptions", {
|
|
109
|
-
enumerable: true,
|
|
110
|
-
configurable: true,
|
|
111
|
-
writable: true,
|
|
112
|
-
value: void 0
|
|
113
|
-
});
|
|
114
101
|
Object.defineProperty(this, "preNavigationHooks", {
|
|
115
102
|
enumerable: true,
|
|
116
103
|
configurable: true,
|
|
@@ -148,14 +135,8 @@ class BrowserCrawler extends basic_1.BasicCrawler {
|
|
|
148
135
|
if (!this.useSessionPool && persistCookiesPerSession) {
|
|
149
136
|
throw new Error('You cannot use "persistCookiesPerSession" without "useSessionPool" set to true.');
|
|
150
137
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
}
|
|
154
|
-
this.navigationTimeoutMillis = (gotoTimeoutSecs || navigationTimeoutSecs) * 1000;
|
|
155
|
-
this.gotoFunction = gotoFunction;
|
|
156
|
-
this.defaultGotoOptions = {
|
|
157
|
-
timeout: this.navigationTimeoutMillis,
|
|
158
|
-
};
|
|
138
|
+
this.launchContext = launchContext;
|
|
139
|
+
this.navigationTimeoutMillis = navigationTimeoutSecs * 1000;
|
|
159
140
|
this.proxyConfiguration = proxyConfiguration;
|
|
160
141
|
this.preNavigationHooks = preNavigationHooks;
|
|
161
142
|
this.postNavigationHooks = postNavigationHooks;
|
|
@@ -165,6 +146,10 @@ class BrowserCrawler extends basic_1.BasicCrawler {
|
|
|
165
146
|
else {
|
|
166
147
|
this.persistCookiesPerSession = false;
|
|
167
148
|
}
|
|
149
|
+
if (launchContext?.userAgent) {
|
|
150
|
+
browserPoolOptions.useFingerprints = false;
|
|
151
|
+
this.log.info('Disabling automatic fingerprint injection because custom user agent has been provided.');
|
|
152
|
+
}
|
|
168
153
|
const { preLaunchHooks = [], postLaunchHooks = [], ...rest } = browserPoolOptions;
|
|
169
154
|
this.browserPool = new browser_pool_1.BrowserPool({
|
|
170
155
|
...rest,
|
|
@@ -188,7 +173,7 @@ class BrowserCrawler extends basic_1.BasicCrawler {
|
|
|
188
173
|
const useIncognitoPages = this.launchContext?.useIncognitoPages;
|
|
189
174
|
if (this.proxyConfiguration && useIncognitoPages) {
|
|
190
175
|
const { session } = crawlingContext;
|
|
191
|
-
const proxyInfo = this.proxyConfiguration.newProxyInfo(session?.id);
|
|
176
|
+
const proxyInfo = await this.proxyConfiguration.newProxyInfo(session?.id);
|
|
192
177
|
crawlingContext.proxyInfo = proxyInfo;
|
|
193
178
|
newPageOptions.proxyUrl = proxyInfo.url;
|
|
194
179
|
if (this.proxyConfiguration.isManInTheMiddle) {
|
|
@@ -209,24 +194,19 @@ class BrowserCrawler extends basic_1.BasicCrawler {
|
|
|
209
194
|
// For example, `sessionPoolOptions.sessionOptions.maxUsageCount` can be `1`.
|
|
210
195
|
// So we must not save the session prior to making sure it was used only once, otherwise we would use it twice.
|
|
211
196
|
const { request, session } = crawlingContext;
|
|
212
|
-
if (this.useSessionPool) {
|
|
213
|
-
const sessionCookies = session.getPuppeteerCookies(request.url);
|
|
214
|
-
if (sessionCookies.length) {
|
|
215
|
-
await crawlingContext.browserController.setCookies(page, sessionCookies);
|
|
216
|
-
(0, timeout_1.tryCancel)();
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
197
|
try {
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
await this._responseHandler(crawlingContext);
|
|
223
|
-
(0, timeout_1.tryCancel)();
|
|
224
|
-
// save cookies
|
|
225
|
-
// TODO: Should we save the cookies also after/only the handle page?
|
|
226
|
-
if (this.persistCookiesPerSession) {
|
|
227
|
-
const cookies = await crawlingContext.browserController.getCookies(page);
|
|
198
|
+
if (!request.skipNavigation) {
|
|
199
|
+
await this._handleNavigation(crawlingContext);
|
|
228
200
|
(0, timeout_1.tryCancel)();
|
|
229
|
-
|
|
201
|
+
await this._responseHandler(crawlingContext);
|
|
202
|
+
(0, timeout_1.tryCancel)();
|
|
203
|
+
// save cookies
|
|
204
|
+
// TODO: Should we save the cookies also after/only the handle page?
|
|
205
|
+
if (this.persistCookiesPerSession) {
|
|
206
|
+
const cookies = await crawlingContext.browserController.getCookies(page);
|
|
207
|
+
(0, timeout_1.tryCancel)();
|
|
208
|
+
session?.setPuppeteerCookies(cookies, request.loadedUrl);
|
|
209
|
+
}
|
|
230
210
|
}
|
|
231
211
|
await (0, timeout_1.addTimeoutToPromise)(() => Promise.resolve(this.userProvidedRequestHandler(crawlingContext)), this.requestHandlerTimeoutMillis, `requestHandler timed out after ${this.requestHandlerTimeoutMillis / 1000} seconds.`);
|
|
232
212
|
(0, timeout_1.tryCancel)();
|
|
@@ -256,16 +236,20 @@ class BrowserCrawler extends basic_1.BasicCrawler {
|
|
|
256
236
|
options: enqueueOptions,
|
|
257
237
|
page,
|
|
258
238
|
requestQueue: await this.getRequestQueue(),
|
|
259
|
-
|
|
239
|
+
originalRequestUrl: new URL(crawlingContext.request.url).origin,
|
|
240
|
+
finalRequestUrl: new URL(crawlingContext.request.loadedUrl ?? crawlingContext.request.url).origin,
|
|
260
241
|
});
|
|
261
242
|
};
|
|
262
243
|
}
|
|
263
244
|
async _handleNavigation(crawlingContext) {
|
|
264
|
-
const gotoOptions = {
|
|
245
|
+
const gotoOptions = { timeout: this.navigationTimeoutMillis };
|
|
246
|
+
const preNavigationHooksCookies = this._getCookieHeaderFromRequest(crawlingContext.request);
|
|
265
247
|
await this._executeHooks(this.preNavigationHooks, crawlingContext, gotoOptions);
|
|
266
248
|
(0, timeout_1.tryCancel)();
|
|
249
|
+
const postNavigationHooksCookies = this._getCookieHeaderFromRequest(crawlingContext.request);
|
|
250
|
+
await this._applyCookies(crawlingContext, preNavigationHooksCookies, postNavigationHooksCookies);
|
|
267
251
|
try {
|
|
268
|
-
crawlingContext.response = await this._navigationHandler(crawlingContext, gotoOptions);
|
|
252
|
+
crawlingContext.response = await this._navigationHandler(crawlingContext, gotoOptions) ?? undefined;
|
|
269
253
|
}
|
|
270
254
|
catch (error) {
|
|
271
255
|
this._handleNavigationTimeout(crawlingContext, error);
|
|
@@ -274,6 +258,16 @@ class BrowserCrawler extends basic_1.BasicCrawler {
|
|
|
274
258
|
(0, timeout_1.tryCancel)();
|
|
275
259
|
await this._executeHooks(this.postNavigationHooks, crawlingContext, gotoOptions);
|
|
276
260
|
}
|
|
261
|
+
async _applyCookies({ session, request, page, browserController }, preHooksCookies, postHooksCookies) {
|
|
262
|
+
const sessionCookie = session?.getPuppeteerCookies(request.url) ?? [];
|
|
263
|
+
const parsedPreHooksCookies = preHooksCookies.split(/ *; */).map((c) => tough_cookie_1.Cookie.parse(c)?.toJSON());
|
|
264
|
+
const parsedPostHooksCookies = postHooksCookies.split(/ *; */).map((c) => tough_cookie_1.Cookie.parse(c)?.toJSON());
|
|
265
|
+
await browserController.setCookies(page, [
|
|
266
|
+
...sessionCookie,
|
|
267
|
+
...parsedPreHooksCookies,
|
|
268
|
+
...parsedPostHooksCookies,
|
|
269
|
+
].filter((c) => typeof c !== 'undefined'));
|
|
270
|
+
}
|
|
277
271
|
/**
|
|
278
272
|
* Marks session bad in case of navigation timeout.
|
|
279
273
|
*/
|
|
@@ -283,14 +277,6 @@ class BrowserCrawler extends basic_1.BasicCrawler {
|
|
|
283
277
|
(0, core_1.handleRequestTimeout)({ session, errorMessage: error.message });
|
|
284
278
|
}
|
|
285
279
|
}
|
|
286
|
-
async _navigationHandler(crawlingContext, gotoOptions) {
|
|
287
|
-
if (!this.gotoFunction) {
|
|
288
|
-
// @TODO: although it is optional in the validation,
|
|
289
|
-
// because when you make automation library specific you can override this handler.
|
|
290
|
-
throw new Error('BrowserCrawler: You must specify a gotoFunction!');
|
|
291
|
-
}
|
|
292
|
-
return this.gotoFunction(crawlingContext, gotoOptions);
|
|
293
|
-
}
|
|
294
280
|
/**
|
|
295
281
|
* Should be overridden in case of different automation library that does not support this response API.
|
|
296
282
|
* @todo: This can be also done as a postNavigation hook except the loadedUrl marking.
|
|
@@ -299,7 +285,7 @@ class BrowserCrawler extends basic_1.BasicCrawler {
|
|
|
299
285
|
const { response, session, request, page } = crawlingContext;
|
|
300
286
|
if (this.sessionPool && response && session) {
|
|
301
287
|
if (typeof response === 'object' && typeof response.status === 'function') {
|
|
302
|
-
|
|
288
|
+
this._throwOnBlockedRequest(session, response.status());
|
|
303
289
|
}
|
|
304
290
|
else {
|
|
305
291
|
this.log.debug('Got a malformed Browser response.', { request, response });
|
|
@@ -313,7 +299,7 @@ class BrowserCrawler extends basic_1.BasicCrawler {
|
|
|
313
299
|
launchContextExtends.session = await this.sessionPool.getSession();
|
|
314
300
|
}
|
|
315
301
|
if (this.proxyConfiguration) {
|
|
316
|
-
const proxyInfo = this.proxyConfiguration.newProxyInfo(launchContextExtends.session
|
|
302
|
+
const proxyInfo = await this.proxyConfiguration.newProxyInfo(launchContextExtends.session?.id);
|
|
317
303
|
launchContext.proxyUrl = proxyInfo.url;
|
|
318
304
|
launchContextExtends.proxyInfo = proxyInfo;
|
|
319
305
|
// Disable SSL verification for MITM proxies
|
|
@@ -358,11 +344,10 @@ Object.defineProperty(BrowserCrawler, "optionsShape", {
|
|
|
358
344
|
value: {
|
|
359
345
|
...basic_1.BasicCrawler.optionsShape,
|
|
360
346
|
handlePageFunction: ow_1.default.optional.function,
|
|
361
|
-
gotoFunction: ow_1.default.optional.function,
|
|
362
|
-
gotoTimeoutSecs: ow_1.default.optional.number.greaterThan(0),
|
|
363
347
|
navigationTimeoutSecs: ow_1.default.optional.number.greaterThan(0),
|
|
364
348
|
preNavigationHooks: ow_1.default.optional.array,
|
|
365
349
|
postNavigationHooks: ow_1.default.optional.array,
|
|
350
|
+
launchContext: ow_1.default.optional.object,
|
|
366
351
|
browserPoolOptions: ow_1.default.object,
|
|
367
352
|
sessionPoolOptions: ow_1.default.optional.object,
|
|
368
353
|
persistCookiesPerSession: ow_1.default.optional.boolean,
|
|
@@ -371,12 +356,16 @@ Object.defineProperty(BrowserCrawler, "optionsShape", {
|
|
|
371
356
|
}
|
|
372
357
|
});
|
|
373
358
|
/** @internal */
|
|
374
|
-
async function browserCrawlerEnqueueLinks({ options, page, requestQueue,
|
|
375
|
-
const baseUrl =
|
|
359
|
+
async function browserCrawlerEnqueueLinks({ options, page, requestQueue, originalRequestUrl, finalRequestUrl, }) {
|
|
360
|
+
const baseUrl = (0, core_1.resolveBaseUrl)({
|
|
361
|
+
enqueueStrategy: options?.strategy,
|
|
362
|
+
finalRequestUrl,
|
|
363
|
+
originalRequestUrl,
|
|
364
|
+
userProvidedBaseUrl: options?.baseUrl,
|
|
365
|
+
});
|
|
376
366
|
const urls = await extractUrlsFromPage(page, options?.selector ?? 'a', baseUrl);
|
|
377
367
|
return (0, core_1.enqueueLinks)({
|
|
378
|
-
|
|
379
|
-
requestQueue: requestQueue ?? await core_1.RequestQueue.open(),
|
|
368
|
+
requestQueue,
|
|
380
369
|
urls,
|
|
381
370
|
baseUrl,
|
|
382
371
|
...options,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser-crawler.js","sourceRoot":"","sources":["../../src/internals/browser-crawler.ts"],"names":[],"mappings":";;;;AAAA,4CAAgE;AAChE,wCAcuB;AACvB,0CAIwB;AAExB,wDAW+B;AAC/B,oDAAoB;AACpB,+CAAsC;AAyOtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,MAAsB,cAKpB,SAAQ,oBAAqB;IAsC3B;;OAEG;IACH,YAAsB,OAAuC;QACzD,IAAA,YAAE,EAAC,OAAO,EAAE,uBAAuB,EAAE,YAAE,CAAC,MAAM,CAAC,UAAU,CAAC,cAAc,CAAC,Y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AAI,CAAC;IACf,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { Dictionary, Constructor } from '@crawlee/utils';
|
|
2
2
|
import { BrowserPlugin, BrowserPluginOptions } from '@crawlee/browser-pool';
|
|
3
3
|
export interface BrowserLaunchContext<TOptions, Launcher> extends BrowserPluginOptions<TOptions> {
|
|
4
|
+
/**
|
|
5
|
+
* URL to a HTTP proxy server. It must define the port number,
|
|
6
|
+
* and it may also contain proxy username and password.
|
|
7
|
+
*
|
|
8
|
+
* Example: `http://bob:pass123@proxy.example.com:1234`.
|
|
9
|
+
*/
|
|
10
|
+
proxyUrl?: string;
|
|
4
11
|
/**
|
|
5
12
|
* If `true` and `executablePath` is not set,
|
|
6
13
|
* the launcher will launch full Google Chrome browser available on the machine
|
|
@@ -11,6 +18,24 @@ export interface BrowserLaunchContext<TOptions, Launcher> extends BrowserPluginO
|
|
|
11
18
|
* @default false
|
|
12
19
|
*/
|
|
13
20
|
useChrome?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* With this option selected, all pages will be opened in a new incognito browser context.
|
|
23
|
+
* This means they will not share cookies nor cache and their resources will not be throttled by one another.
|
|
24
|
+
* @default false
|
|
25
|
+
*/
|
|
26
|
+
useIncognitoPages?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Sets the [User Data Directory](https://chromium.googlesource.com/chromium/src/+/master/docs/user_data_dir.md) path.
|
|
29
|
+
* The user data directory contains profile data such as history, bookmarks, and cookies, as well as other per-installation local state.
|
|
30
|
+
* If not specified, a temporary directory is used instead.
|
|
31
|
+
*/
|
|
32
|
+
userDataDir?: string;
|
|
33
|
+
/**
|
|
34
|
+
* The `User-Agent` HTTP header used by the browser.
|
|
35
|
+
* If not provided, the function sets `User-Agent` to a reasonable default
|
|
36
|
+
* to reduce the chance of detection of the crawler.
|
|
37
|
+
*/
|
|
38
|
+
userAgent?: string;
|
|
14
39
|
launcher?: Launcher;
|
|
15
40
|
}
|
|
16
41
|
/**
|
|
@@ -31,6 +56,7 @@ export declare abstract class BrowserLauncher<Plugin extends BrowserPlugin, Laun
|
|
|
31
56
|
useIncognitoPages: import("ow").BooleanPredicate & import("ow").BasePredicate<boolean | undefined>;
|
|
32
57
|
userDataDir: import("ow").StringPredicate & import("ow").BasePredicate<string | undefined>;
|
|
33
58
|
launchOptions: import("ow").ObjectPredicate<object> & import("ow").BasePredicate<object | undefined>;
|
|
59
|
+
userAgent: import("ow").StringPredicate & import("ow").BasePredicate<string | undefined>;
|
|
34
60
|
};
|
|
35
61
|
static requireLauncherOrThrow<T>(launcher: string, apifyImageName: string): T;
|
|
36
62
|
/**
|
|
@@ -46,9 +72,7 @@ export declare abstract class BrowserLauncher<Plugin extends BrowserPlugin, Laun
|
|
|
46
72
|
* @returns Browser instance.
|
|
47
73
|
*/
|
|
48
74
|
launch(): LaunchResult;
|
|
49
|
-
createLaunchOptions():
|
|
50
|
-
args?: string[];
|
|
51
|
-
} & Dictionary;
|
|
75
|
+
createLaunchOptions(): Dictionary;
|
|
52
76
|
protected _getDefaultHeadlessOption(): boolean;
|
|
53
77
|
protected _getChromeExecutablePath(): string;
|
|
54
78
|
/**
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser-launcher.d.ts","sourceRoot":"","sources":["../../src/internals/browser-launcher.ts"],"names":[],"mappings":"AAIA,OAAO,EACH,UAAU,EACV,WAAW,EACd,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACH,aAAa,EACb,oBAAoB,EACvB,MAAM,uBAAuB,CAAC;AAO/B,MAAM,WAAW,oBAAoB,CAAC,QAAQ,EAAE,QAAQ,CAAE,SAAQ,oBAAoB,CAAC,QAAQ,CAAC;IAC5F;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;;;;;;OAQG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;;;MAIE;IACF,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAE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8BnD,SAAS,CAAC,yBAAyB,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI;CAe/D"}
|
|
@@ -6,6 +6,10 @@ const os_1 = tslib_1.__importDefault(require("os"));
|
|
|
6
6
|
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
7
7
|
const ow_1 = tslib_1.__importDefault(require("ow"));
|
|
8
8
|
const consts_1 = require("@apify/consts");
|
|
9
|
+
const DEFAULT_VIEWPORT = {
|
|
10
|
+
width: 1366,
|
|
11
|
+
height: 768,
|
|
12
|
+
};
|
|
9
13
|
/**
|
|
10
14
|
* Abstract class for creating browser launchers, such as `PlaywrightLauncher` and `PuppeteerLauncher`.
|
|
11
15
|
* @ignore
|
|
@@ -58,12 +62,13 @@ class BrowserLauncher {
|
|
|
58
62
|
writable: true,
|
|
59
63
|
value: void 0
|
|
60
64
|
});
|
|
61
|
-
const { launcher, proxyUrl, useChrome, launchOptions = {}, ...otherLaunchContextProps } = launchContext;
|
|
65
|
+
const { launcher, proxyUrl, useChrome, userAgent, launchOptions = {}, ...otherLaunchContextProps } = launchContext;
|
|
62
66
|
this._validateProxyUrlProtocol(proxyUrl);
|
|
63
67
|
// those need to be reassigned otherwise they are {} in types
|
|
64
68
|
this.launcher = launcher;
|
|
65
69
|
this.proxyUrl = proxyUrl;
|
|
66
70
|
this.useChrome = useChrome;
|
|
71
|
+
this.userAgent = userAgent;
|
|
67
72
|
this.launchOptions = launchOptions;
|
|
68
73
|
this.otherLaunchContextProps = otherLaunchContextProps;
|
|
69
74
|
}
|
|
@@ -76,16 +81,10 @@ class BrowserLauncher {
|
|
|
76
81
|
if (e.code === 'MODULE_NOT_FOUND') {
|
|
77
82
|
const msg = `Cannot find module '${launcher}'. Did you you install the '${launcher}' package?\n`
|
|
78
83
|
+ `Make sure you have '${launcher}' in your package.json dependencies and in your package-lock.json, if you use it.`;
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
// TODO: this might be doable better to know if its used on apify or not...
|
|
83
|
-
if (apify.isAtHome()) {
|
|
84
|
-
e.message = `${msg}\nOn the Apify platform, '${launcher}' can only be used with the ${apifyImageName} Docker image.`;
|
|
85
|
-
}
|
|
86
|
-
// eslint-disable-next-line no-empty
|
|
84
|
+
// TODO we should not depend on apify env vars here ideally
|
|
85
|
+
if (process.env.APIFY_IS_AT_HOME) {
|
|
86
|
+
e.message = `${msg}\nOn the Apify platform, '${launcher}' can only be used with the ${apifyImageName} Docker image.`;
|
|
87
87
|
}
|
|
88
|
-
catch { }
|
|
89
88
|
}
|
|
90
89
|
throw err;
|
|
91
90
|
}
|
|
@@ -111,8 +110,17 @@ class BrowserLauncher {
|
|
|
111
110
|
}
|
|
112
111
|
createLaunchOptions() {
|
|
113
112
|
const launchOptions = {
|
|
113
|
+
args: [],
|
|
114
|
+
defaultViewport: DEFAULT_VIEWPORT,
|
|
114
115
|
...this.launchOptions,
|
|
115
116
|
};
|
|
117
|
+
// TODO is this needed? should be controlled via public options preferably
|
|
118
|
+
if (process.env.APIFY_IS_AT_HOME) {
|
|
119
|
+
launchOptions.args.push('--no-sandbox');
|
|
120
|
+
}
|
|
121
|
+
if (this.userAgent) {
|
|
122
|
+
launchOptions.args.push(`--user-agent=${this.userAgent}`);
|
|
123
|
+
}
|
|
116
124
|
if (launchOptions.headless == null) {
|
|
117
125
|
launchOptions.headless = this._getDefaultHeadlessOption();
|
|
118
126
|
}
|
|
@@ -184,6 +192,7 @@ Object.defineProperty(BrowserLauncher, "optionsShape", {
|
|
|
184
192
|
useIncognitoPages: ow_1.default.optional.boolean,
|
|
185
193
|
userDataDir: ow_1.default.optional.string,
|
|
186
194
|
launchOptions: ow_1.default.optional.object,
|
|
195
|
+
userAgent: ow_1.default.optional.string,
|
|
187
196
|
}
|
|
188
197
|
});
|
|
189
198
|
//# sourceMappingURL=browser-launcher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser-launcher.js","sourceRoot":"","sources":["../../src/internals/browser-launcher.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,QAAQ,GAAG,CAAC,CAAC;SAC7E;QAED,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC;QAE9B,IAAI,GAAG,CAAC,QAAQ,IAAI,GAAG,CAAC,QAAQ,EAAE;YAC9B,IAAI,GAAG,CAAC,QAAQ,KAAK,OAAO,IAAI,GAAG,CAAC,QAAQ,KAAK,QAAQ,EAAE;gBACvD,MAAM,IAAI,KAAK,CAAC,kFAAkF,CAAC,CAAC;aACvG;SACJ;IACL,CAAC;;AA3KL,0CA4KC;AA5JG;;;;WAAgC;QAC5B,QAAQ,EAAE,YAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG;QAChC,SAAS,EAAE,YAAE,CAAC,QAAQ,CAAC,OAAO;QAC9B,iBAAiB,EAAE,YAAE,CAAC,QAAQ,CAAC,OAAO;QACtC,WAAW,EAAE,YAAE,CAAC,QAAQ,CAAC,MAAM;QAC/B,aAAa,EAAE,YAAE,CAAC,QAAQ,CAAC,MAAM;QACjC,SAAS,EAAE,YAAE,CAAC,QAAQ,CAAC,MAAM;KAChC;GAAC"}
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crawlee/browser",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.30",
|
|
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
|
-
"types": "
|
|
8
|
+
"types": "index.d.ts",
|
|
9
9
|
"exports": {
|
|
10
10
|
".": {
|
|
11
|
-
"import": "./
|
|
12
|
-
"require": "./
|
|
11
|
+
"import": "./index.mjs",
|
|
12
|
+
"require": "./index.js"
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
15
|
"keywords": [
|
|
@@ -39,20 +39,17 @@
|
|
|
39
39
|
"url": "https://github.com/apify/apify-js/issues"
|
|
40
40
|
},
|
|
41
41
|
"homepage": "https://sdk.apify.com/",
|
|
42
|
-
"files": [
|
|
43
|
-
"dist"
|
|
44
|
-
],
|
|
45
42
|
"scripts": {
|
|
46
43
|
"build": "npm run clean && npm run compile && npm run copy",
|
|
47
44
|
"clean": "rimraf ./dist",
|
|
48
|
-
"compile": "tsc -p tsconfig.build.json && gen-esm-wrapper ./
|
|
45
|
+
"compile": "tsc -p tsconfig.build.json && gen-esm-wrapper ./index.js ./index.mjs",
|
|
49
46
|
"copy": "ts-node -T ../../scripts/copy.ts"
|
|
50
47
|
},
|
|
51
48
|
"publishConfig": {
|
|
52
49
|
"access": "public"
|
|
53
50
|
},
|
|
54
51
|
"dependencies": {
|
|
55
|
-
"@crawlee/basic": "^3.0.0-alpha.
|
|
56
|
-
|
|
57
|
-
|
|
52
|
+
"@crawlee/basic": "^3.0.0-alpha.30",
|
|
53
|
+
"tough-cookie": "^4.0.0"
|
|
54
|
+
}
|
|
58
55
|
}
|