@letsscrapedata/controller 0.0.12 → 0.0.14
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/index.cjs +10 -10
- package/dist/index.d.cts +9 -5
- package/dist/index.d.ts +9 -5
- package/dist/index.js +10 -10
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -763,8 +763,8 @@ var PlaywrightPage = class extends import_node_events.default {
|
|
|
763
763
|
if (!this.#page) {
|
|
764
764
|
throw new Error("No valid page");
|
|
765
765
|
}
|
|
766
|
-
await this.#page.pdf(options);
|
|
767
|
-
return
|
|
766
|
+
const buffer = await this.#page.pdf(options);
|
|
767
|
+
return buffer;
|
|
768
768
|
}
|
|
769
769
|
async screenshot(options) {
|
|
770
770
|
if (!this.#page) {
|
|
@@ -952,7 +952,7 @@ var PlaywrightPage = class extends import_node_events.default {
|
|
|
952
952
|
return;
|
|
953
953
|
}
|
|
954
954
|
for (const option of this.#responseInterceptionOptions) {
|
|
955
|
-
const { requestMatch, responseMatch, responseItems, handler, handlerOptions } = option;
|
|
955
|
+
const { requestMatch, responseMatch, responseItems, handler, handlerOptions = {} } = option;
|
|
956
956
|
let matchedFlag = !requestMatch || this.#checkRequestMatch(request, requestMatch);
|
|
957
957
|
if (matchedFlag && responseMatch) {
|
|
958
958
|
const { minLength, maxLength } = responseMatch;
|
|
@@ -981,7 +981,7 @@ var PlaywrightPage = class extends import_node_events.default {
|
|
|
981
981
|
(0, import_utils2.loginfo)(`##browser cache matched response: ${requestUrl}`);
|
|
982
982
|
}
|
|
983
983
|
if (typeof handler === "function") {
|
|
984
|
-
await handler(response, handlerOptions);
|
|
984
|
+
await handler(response, handlerOptions, pageUrl);
|
|
985
985
|
}
|
|
986
986
|
}
|
|
987
987
|
return;
|
|
@@ -2231,8 +2231,8 @@ var PuppeteerPage = class extends import_node_events4.default {
|
|
|
2231
2231
|
if (!this.#page) {
|
|
2232
2232
|
throw new Error("No valid page");
|
|
2233
2233
|
}
|
|
2234
|
-
await this.#page.pdf(options);
|
|
2235
|
-
return
|
|
2234
|
+
const buffer = await this.#page.pdf(options);
|
|
2235
|
+
return buffer;
|
|
2236
2236
|
}
|
|
2237
2237
|
async screenshot(options) {
|
|
2238
2238
|
if (!this.#page) {
|
|
@@ -2408,18 +2408,18 @@ var PuppeteerPage = class extends import_node_events4.default {
|
|
|
2408
2408
|
return false;
|
|
2409
2409
|
}
|
|
2410
2410
|
this.#responseInterceptionNum++;
|
|
2411
|
-
const pageUrl = this.#page.url();
|
|
2412
2411
|
this.#page.on("response", async (response) => {
|
|
2413
2412
|
try {
|
|
2414
|
-
if (!response.ok()) {
|
|
2413
|
+
if (!response.ok() || !this.#page) {
|
|
2415
2414
|
return false;
|
|
2416
2415
|
}
|
|
2416
|
+
const pageUrl = this.#page.url();
|
|
2417
2417
|
const request = response.request();
|
|
2418
2418
|
if (!request) {
|
|
2419
2419
|
return false;
|
|
2420
2420
|
}
|
|
2421
2421
|
for (const option of actOptions) {
|
|
2422
|
-
const { requestMatch, responseMatch, responseItems, handler, handlerOptions } = option;
|
|
2422
|
+
const { requestMatch, responseMatch, responseItems, handler, handlerOptions = {} } = option;
|
|
2423
2423
|
let matchedFlag = !requestMatch || this.#checkRequestMatch(request, requestMatch);
|
|
2424
2424
|
if (matchedFlag && responseMatch) {
|
|
2425
2425
|
const { minLength, maxLength } = responseMatch;
|
|
@@ -2447,7 +2447,7 @@ var PuppeteerPage = class extends import_node_events4.default {
|
|
|
2447
2447
|
});
|
|
2448
2448
|
}
|
|
2449
2449
|
if (typeof handler === "function") {
|
|
2450
|
-
await handler(response, handlerOptions);
|
|
2450
|
+
await handler(response, handlerOptions, pageUrl);
|
|
2451
2451
|
}
|
|
2452
2452
|
}
|
|
2453
2453
|
return true;
|
package/dist/index.d.cts
CHANGED
|
@@ -456,7 +456,7 @@ interface ResponseMatch {
|
|
|
456
456
|
maxLength?: number;
|
|
457
457
|
}
|
|
458
458
|
type ResponseHandlerOptions = Record<string, any>;
|
|
459
|
-
type ResponseHandler = (response: AllResponse, options
|
|
459
|
+
type ResponseHandler = (response: AllResponse, options: ResponseHandlerOptions, pageUrl: string) => Promise<void> | void;
|
|
460
460
|
interface ResponseInterceptionItem {
|
|
461
461
|
/**
|
|
462
462
|
* page.url()
|
|
@@ -490,6 +490,10 @@ interface ResponseInterceptionOption {
|
|
|
490
490
|
* handler will be called if handler is a function
|
|
491
491
|
*/
|
|
492
492
|
handler?: ResponseHandler;
|
|
493
|
+
/**
|
|
494
|
+
* valid only if handler is a function
|
|
495
|
+
* @default {}
|
|
496
|
+
*/
|
|
493
497
|
handlerOptions?: ResponseHandlerOptions;
|
|
494
498
|
}
|
|
495
499
|
interface PDFMargin {
|
|
@@ -802,7 +806,7 @@ interface LsdPage extends EventEmitter {
|
|
|
802
806
|
pageHeight(): Promise<number>;
|
|
803
807
|
pageInfo(): PageInfo;
|
|
804
808
|
pageWidth(): Promise<number>;
|
|
805
|
-
pdf(options?: PDFOptions): Promise<
|
|
809
|
+
pdf(options?: PDFOptions): Promise<Buffer>;
|
|
806
810
|
screenshot(options?: ScreenshotOptions): Promise<Buffer>;
|
|
807
811
|
scrollBy(x: number, y: number): Promise<boolean>;
|
|
808
812
|
scrollTo(x: number, y: number): Promise<boolean>;
|
|
@@ -1001,7 +1005,7 @@ declare class PlaywrightPage extends EventEmitter implements LsdPage {
|
|
|
1001
1005
|
pageHeight(): Promise<number>;
|
|
1002
1006
|
pageInfo(): PageInfo;
|
|
1003
1007
|
pageWidth(): Promise<number>;
|
|
1004
|
-
pdf(options?: PDFOptions | undefined): Promise<
|
|
1008
|
+
pdf(options?: PDFOptions | undefined): Promise<Buffer>;
|
|
1005
1009
|
screenshot(options?: ScreenshotOptions): Promise<Buffer>;
|
|
1006
1010
|
scrollBy(x: number, y: number): Promise<boolean>;
|
|
1007
1011
|
scrollTo(x: number, y: number): Promise<boolean>;
|
|
@@ -1109,7 +1113,7 @@ declare class PuppeteerPage extends EventEmitter implements LsdPage {
|
|
|
1109
1113
|
pageHeight(): Promise<number>;
|
|
1110
1114
|
pageInfo(): PageInfo;
|
|
1111
1115
|
pageWidth(): Promise<number>;
|
|
1112
|
-
pdf(options?: PDFOptions | undefined): Promise<
|
|
1116
|
+
pdf(options?: PDFOptions | undefined): Promise<Buffer>;
|
|
1113
1117
|
screenshot(options?: ScreenshotOptions): Promise<Buffer>;
|
|
1114
1118
|
scrollBy(x: number, y: number): Promise<boolean>;
|
|
1115
1119
|
scrollTo(x: number, y: number): Promise<boolean>;
|
|
@@ -1181,7 +1185,7 @@ declare class CheerioPage extends EventEmitter implements LsdPage {
|
|
|
1181
1185
|
pageHeight(): Promise<number>;
|
|
1182
1186
|
pageInfo(): PageInfo;
|
|
1183
1187
|
pageWidth(): Promise<number>;
|
|
1184
|
-
pdf(): Promise<
|
|
1188
|
+
pdf(): Promise<Buffer>;
|
|
1185
1189
|
screenshot(): Promise<Buffer>;
|
|
1186
1190
|
scrollBy(): Promise<boolean>;
|
|
1187
1191
|
scrollTo(): Promise<boolean>;
|
package/dist/index.d.ts
CHANGED
|
@@ -456,7 +456,7 @@ interface ResponseMatch {
|
|
|
456
456
|
maxLength?: number;
|
|
457
457
|
}
|
|
458
458
|
type ResponseHandlerOptions = Record<string, any>;
|
|
459
|
-
type ResponseHandler = (response: AllResponse, options
|
|
459
|
+
type ResponseHandler = (response: AllResponse, options: ResponseHandlerOptions, pageUrl: string) => Promise<void> | void;
|
|
460
460
|
interface ResponseInterceptionItem {
|
|
461
461
|
/**
|
|
462
462
|
* page.url()
|
|
@@ -490,6 +490,10 @@ interface ResponseInterceptionOption {
|
|
|
490
490
|
* handler will be called if handler is a function
|
|
491
491
|
*/
|
|
492
492
|
handler?: ResponseHandler;
|
|
493
|
+
/**
|
|
494
|
+
* valid only if handler is a function
|
|
495
|
+
* @default {}
|
|
496
|
+
*/
|
|
493
497
|
handlerOptions?: ResponseHandlerOptions;
|
|
494
498
|
}
|
|
495
499
|
interface PDFMargin {
|
|
@@ -802,7 +806,7 @@ interface LsdPage extends EventEmitter {
|
|
|
802
806
|
pageHeight(): Promise<number>;
|
|
803
807
|
pageInfo(): PageInfo;
|
|
804
808
|
pageWidth(): Promise<number>;
|
|
805
|
-
pdf(options?: PDFOptions): Promise<
|
|
809
|
+
pdf(options?: PDFOptions): Promise<Buffer>;
|
|
806
810
|
screenshot(options?: ScreenshotOptions): Promise<Buffer>;
|
|
807
811
|
scrollBy(x: number, y: number): Promise<boolean>;
|
|
808
812
|
scrollTo(x: number, y: number): Promise<boolean>;
|
|
@@ -1001,7 +1005,7 @@ declare class PlaywrightPage extends EventEmitter implements LsdPage {
|
|
|
1001
1005
|
pageHeight(): Promise<number>;
|
|
1002
1006
|
pageInfo(): PageInfo;
|
|
1003
1007
|
pageWidth(): Promise<number>;
|
|
1004
|
-
pdf(options?: PDFOptions | undefined): Promise<
|
|
1008
|
+
pdf(options?: PDFOptions | undefined): Promise<Buffer>;
|
|
1005
1009
|
screenshot(options?: ScreenshotOptions): Promise<Buffer>;
|
|
1006
1010
|
scrollBy(x: number, y: number): Promise<boolean>;
|
|
1007
1011
|
scrollTo(x: number, y: number): Promise<boolean>;
|
|
@@ -1109,7 +1113,7 @@ declare class PuppeteerPage extends EventEmitter implements LsdPage {
|
|
|
1109
1113
|
pageHeight(): Promise<number>;
|
|
1110
1114
|
pageInfo(): PageInfo;
|
|
1111
1115
|
pageWidth(): Promise<number>;
|
|
1112
|
-
pdf(options?: PDFOptions | undefined): Promise<
|
|
1116
|
+
pdf(options?: PDFOptions | undefined): Promise<Buffer>;
|
|
1113
1117
|
screenshot(options?: ScreenshotOptions): Promise<Buffer>;
|
|
1114
1118
|
scrollBy(x: number, y: number): Promise<boolean>;
|
|
1115
1119
|
scrollTo(x: number, y: number): Promise<boolean>;
|
|
@@ -1181,7 +1185,7 @@ declare class CheerioPage extends EventEmitter implements LsdPage {
|
|
|
1181
1185
|
pageHeight(): Promise<number>;
|
|
1182
1186
|
pageInfo(): PageInfo;
|
|
1183
1187
|
pageWidth(): Promise<number>;
|
|
1184
|
-
pdf(): Promise<
|
|
1188
|
+
pdf(): Promise<Buffer>;
|
|
1185
1189
|
screenshot(): Promise<Buffer>;
|
|
1186
1190
|
scrollBy(): Promise<boolean>;
|
|
1187
1191
|
scrollTo(): Promise<boolean>;
|
package/dist/index.js
CHANGED
|
@@ -743,8 +743,8 @@ var PlaywrightPage = class extends EventEmitter {
|
|
|
743
743
|
if (!this.#page) {
|
|
744
744
|
throw new Error("No valid page");
|
|
745
745
|
}
|
|
746
|
-
await this.#page.pdf(options);
|
|
747
|
-
return
|
|
746
|
+
const buffer = await this.#page.pdf(options);
|
|
747
|
+
return buffer;
|
|
748
748
|
}
|
|
749
749
|
async screenshot(options) {
|
|
750
750
|
if (!this.#page) {
|
|
@@ -932,7 +932,7 @@ var PlaywrightPage = class extends EventEmitter {
|
|
|
932
932
|
return;
|
|
933
933
|
}
|
|
934
934
|
for (const option of this.#responseInterceptionOptions) {
|
|
935
|
-
const { requestMatch, responseMatch, responseItems, handler, handlerOptions } = option;
|
|
935
|
+
const { requestMatch, responseMatch, responseItems, handler, handlerOptions = {} } = option;
|
|
936
936
|
let matchedFlag = !requestMatch || this.#checkRequestMatch(request, requestMatch);
|
|
937
937
|
if (matchedFlag && responseMatch) {
|
|
938
938
|
const { minLength, maxLength } = responseMatch;
|
|
@@ -961,7 +961,7 @@ var PlaywrightPage = class extends EventEmitter {
|
|
|
961
961
|
loginfo(`##browser cache matched response: ${requestUrl}`);
|
|
962
962
|
}
|
|
963
963
|
if (typeof handler === "function") {
|
|
964
|
-
await handler(response, handlerOptions);
|
|
964
|
+
await handler(response, handlerOptions, pageUrl);
|
|
965
965
|
}
|
|
966
966
|
}
|
|
967
967
|
return;
|
|
@@ -2211,8 +2211,8 @@ var PuppeteerPage = class extends EventEmitter4 {
|
|
|
2211
2211
|
if (!this.#page) {
|
|
2212
2212
|
throw new Error("No valid page");
|
|
2213
2213
|
}
|
|
2214
|
-
await this.#page.pdf(options);
|
|
2215
|
-
return
|
|
2214
|
+
const buffer = await this.#page.pdf(options);
|
|
2215
|
+
return buffer;
|
|
2216
2216
|
}
|
|
2217
2217
|
async screenshot(options) {
|
|
2218
2218
|
if (!this.#page) {
|
|
@@ -2388,18 +2388,18 @@ var PuppeteerPage = class extends EventEmitter4 {
|
|
|
2388
2388
|
return false;
|
|
2389
2389
|
}
|
|
2390
2390
|
this.#responseInterceptionNum++;
|
|
2391
|
-
const pageUrl = this.#page.url();
|
|
2392
2391
|
this.#page.on("response", async (response) => {
|
|
2393
2392
|
try {
|
|
2394
|
-
if (!response.ok()) {
|
|
2393
|
+
if (!response.ok() || !this.#page) {
|
|
2395
2394
|
return false;
|
|
2396
2395
|
}
|
|
2396
|
+
const pageUrl = this.#page.url();
|
|
2397
2397
|
const request = response.request();
|
|
2398
2398
|
if (!request) {
|
|
2399
2399
|
return false;
|
|
2400
2400
|
}
|
|
2401
2401
|
for (const option of actOptions) {
|
|
2402
|
-
const { requestMatch, responseMatch, responseItems, handler, handlerOptions } = option;
|
|
2402
|
+
const { requestMatch, responseMatch, responseItems, handler, handlerOptions = {} } = option;
|
|
2403
2403
|
let matchedFlag = !requestMatch || this.#checkRequestMatch(request, requestMatch);
|
|
2404
2404
|
if (matchedFlag && responseMatch) {
|
|
2405
2405
|
const { minLength, maxLength } = responseMatch;
|
|
@@ -2427,7 +2427,7 @@ var PuppeteerPage = class extends EventEmitter4 {
|
|
|
2427
2427
|
});
|
|
2428
2428
|
}
|
|
2429
2429
|
if (typeof handler === "function") {
|
|
2430
|
-
await handler(response, handlerOptions);
|
|
2430
|
+
await handler(response, handlerOptions, pageUrl);
|
|
2431
2431
|
}
|
|
2432
2432
|
}
|
|
2433
2433
|
return true;
|
package/package.json
CHANGED