@letsscrapedata/controller 0.0.17 → 0.0.19
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 +13 -8
- package/dist/index.js +13 -8
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -160,7 +160,7 @@ var PlaywrightElement = class _PlaywrightElement {
|
|
|
160
160
|
if (selector !== ".") {
|
|
161
161
|
locators = await parent2.locator(selector).all();
|
|
162
162
|
} else {
|
|
163
|
-
|
|
163
|
+
locators = [this.#locator];
|
|
164
164
|
}
|
|
165
165
|
}
|
|
166
166
|
retObj.locators = locators;
|
|
@@ -329,6 +329,7 @@ var PlaywrightPage = class extends import_node_events.default {
|
|
|
329
329
|
#resquestInterceptionOptions;
|
|
330
330
|
#responseInterceptionOptions;
|
|
331
331
|
#client;
|
|
332
|
+
#responseCb;
|
|
332
333
|
#hasValidUrl(page) {
|
|
333
334
|
const url = page.url();
|
|
334
335
|
return url.toLowerCase().startsWith("http");
|
|
@@ -541,6 +542,7 @@ var PlaywrightPage = class extends import_node_events.default {
|
|
|
541
542
|
this.#resquestInterceptionOptions = [];
|
|
542
543
|
this.#responseInterceptionOptions = [];
|
|
543
544
|
this.#client = null;
|
|
545
|
+
this.#responseCb = null;
|
|
544
546
|
this.#addPageOn();
|
|
545
547
|
}
|
|
546
548
|
async bringToFront() {
|
|
@@ -578,7 +580,9 @@ var PlaywrightPage = class extends import_node_events.default {
|
|
|
578
580
|
}
|
|
579
581
|
try {
|
|
580
582
|
if (this.#responseInterceptionOptions.length > 0) {
|
|
581
|
-
|
|
583
|
+
if (this.#responseCb) {
|
|
584
|
+
this.#page.removeListener("response", this.#responseCb);
|
|
585
|
+
}
|
|
582
586
|
this.#responseInterceptionOptions = [];
|
|
583
587
|
}
|
|
584
588
|
return true;
|
|
@@ -941,7 +945,7 @@ var PlaywrightPage = class extends import_node_events.default {
|
|
|
941
945
|
}
|
|
942
946
|
return true;
|
|
943
947
|
}
|
|
944
|
-
async #
|
|
948
|
+
async #responseListener(response) {
|
|
945
949
|
try {
|
|
946
950
|
const pageUrl = this.#page ? this.#page.url() : "";
|
|
947
951
|
if (!response.ok()) {
|
|
@@ -1008,7 +1012,8 @@ var PlaywrightPage = class extends import_node_events.default {
|
|
|
1008
1012
|
}
|
|
1009
1013
|
}
|
|
1010
1014
|
if (firstResponseInterception && this.#responseInterceptionOptions.length > 0) {
|
|
1011
|
-
this.#
|
|
1015
|
+
this.#responseCb = this.#responseListener.bind(this);
|
|
1016
|
+
this.#page.on("response", this.#responseCb);
|
|
1012
1017
|
}
|
|
1013
1018
|
return true;
|
|
1014
1019
|
}
|
|
@@ -1394,7 +1399,7 @@ var PlaywrightBrowser = class extends import_node_events3.default {
|
|
|
1394
1399
|
return this.#options.maxPagesPerBrowserContext ? this.#options.maxPagesPerBrowserContext : 20;
|
|
1395
1400
|
}
|
|
1396
1401
|
#maxPageFreeSeconds() {
|
|
1397
|
-
return this.#options.maxPageFreeSeconds ? this.#options.maxPageFreeSeconds :
|
|
1402
|
+
return this.#options.maxPageFreeSeconds ? this.#options.maxPageFreeSeconds : 900;
|
|
1398
1403
|
}
|
|
1399
1404
|
// 构造函数:缺省只能由LsdBrowserController.launch/connect调用创建实例!!!
|
|
1400
1405
|
constructor(browser, browerType, browserCreateMethod, options, browserIdx = 0) {
|
|
@@ -1402,7 +1407,7 @@ var PlaywrightBrowser = class extends import_node_events3.default {
|
|
|
1402
1407
|
throw new Error(`Invalid playwright browser parameter`);
|
|
1403
1408
|
}
|
|
1404
1409
|
super();
|
|
1405
|
-
const { closeFreePagesIntervalSeconds =
|
|
1410
|
+
const { closeFreePagesIntervalSeconds = 300, maxPageFreeSeconds = 900, headless = false, executablePath = "" } = options;
|
|
1406
1411
|
this.#browser = browser;
|
|
1407
1412
|
this.#browserIdx = browserIdx;
|
|
1408
1413
|
this.#lsdBrowserContexts = [];
|
|
@@ -2862,7 +2867,7 @@ var PuppeteerBrowser = class extends import_node_events6.default {
|
|
|
2862
2867
|
return this.#options.maxPagesPerBrowserContext ? this.#options.maxPagesPerBrowserContext : 20;
|
|
2863
2868
|
}
|
|
2864
2869
|
#maxPageFreeSeconds() {
|
|
2865
|
-
return this.#options.maxPageFreeSeconds ? this.#options.maxPageFreeSeconds :
|
|
2870
|
+
return this.#options.maxPageFreeSeconds ? this.#options.maxPageFreeSeconds : 900;
|
|
2866
2871
|
}
|
|
2867
2872
|
#userAgent() {
|
|
2868
2873
|
return this.#options.userAgent ? this.#options.userAgent : "";
|
|
@@ -2873,7 +2878,7 @@ var PuppeteerBrowser = class extends import_node_events6.default {
|
|
|
2873
2878
|
throw new Error(`Invalid puppeteer browser parameter`);
|
|
2874
2879
|
}
|
|
2875
2880
|
super();
|
|
2876
|
-
const { closeFreePagesIntervalSeconds =
|
|
2881
|
+
const { closeFreePagesIntervalSeconds = 300, maxPageFreeSeconds = 900, headless = false, executablePath = "" } = options;
|
|
2877
2882
|
this.#browser = browser;
|
|
2878
2883
|
this.#browserIdx = browserIdx;
|
|
2879
2884
|
this.#lsdBrowserContexts = [];
|
package/dist/index.js
CHANGED
|
@@ -140,7 +140,7 @@ var PlaywrightElement = class _PlaywrightElement {
|
|
|
140
140
|
if (selector !== ".") {
|
|
141
141
|
locators = await parent2.locator(selector).all();
|
|
142
142
|
} else {
|
|
143
|
-
|
|
143
|
+
locators = [this.#locator];
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
146
|
retObj.locators = locators;
|
|
@@ -309,6 +309,7 @@ var PlaywrightPage = class extends EventEmitter {
|
|
|
309
309
|
#resquestInterceptionOptions;
|
|
310
310
|
#responseInterceptionOptions;
|
|
311
311
|
#client;
|
|
312
|
+
#responseCb;
|
|
312
313
|
#hasValidUrl(page) {
|
|
313
314
|
const url = page.url();
|
|
314
315
|
return url.toLowerCase().startsWith("http");
|
|
@@ -521,6 +522,7 @@ var PlaywrightPage = class extends EventEmitter {
|
|
|
521
522
|
this.#resquestInterceptionOptions = [];
|
|
522
523
|
this.#responseInterceptionOptions = [];
|
|
523
524
|
this.#client = null;
|
|
525
|
+
this.#responseCb = null;
|
|
524
526
|
this.#addPageOn();
|
|
525
527
|
}
|
|
526
528
|
async bringToFront() {
|
|
@@ -558,7 +560,9 @@ var PlaywrightPage = class extends EventEmitter {
|
|
|
558
560
|
}
|
|
559
561
|
try {
|
|
560
562
|
if (this.#responseInterceptionOptions.length > 0) {
|
|
561
|
-
|
|
563
|
+
if (this.#responseCb) {
|
|
564
|
+
this.#page.removeListener("response", this.#responseCb);
|
|
565
|
+
}
|
|
562
566
|
this.#responseInterceptionOptions = [];
|
|
563
567
|
}
|
|
564
568
|
return true;
|
|
@@ -921,7 +925,7 @@ var PlaywrightPage = class extends EventEmitter {
|
|
|
921
925
|
}
|
|
922
926
|
return true;
|
|
923
927
|
}
|
|
924
|
-
async #
|
|
928
|
+
async #responseListener(response) {
|
|
925
929
|
try {
|
|
926
930
|
const pageUrl = this.#page ? this.#page.url() : "";
|
|
927
931
|
if (!response.ok()) {
|
|
@@ -988,7 +992,8 @@ var PlaywrightPage = class extends EventEmitter {
|
|
|
988
992
|
}
|
|
989
993
|
}
|
|
990
994
|
if (firstResponseInterception && this.#responseInterceptionOptions.length > 0) {
|
|
991
|
-
this.#
|
|
995
|
+
this.#responseCb = this.#responseListener.bind(this);
|
|
996
|
+
this.#page.on("response", this.#responseCb);
|
|
992
997
|
}
|
|
993
998
|
return true;
|
|
994
999
|
}
|
|
@@ -1374,7 +1379,7 @@ var PlaywrightBrowser = class extends EventEmitter3 {
|
|
|
1374
1379
|
return this.#options.maxPagesPerBrowserContext ? this.#options.maxPagesPerBrowserContext : 20;
|
|
1375
1380
|
}
|
|
1376
1381
|
#maxPageFreeSeconds() {
|
|
1377
|
-
return this.#options.maxPageFreeSeconds ? this.#options.maxPageFreeSeconds :
|
|
1382
|
+
return this.#options.maxPageFreeSeconds ? this.#options.maxPageFreeSeconds : 900;
|
|
1378
1383
|
}
|
|
1379
1384
|
// 构造函数:缺省只能由LsdBrowserController.launch/connect调用创建实例!!!
|
|
1380
1385
|
constructor(browser, browerType, browserCreateMethod, options, browserIdx = 0) {
|
|
@@ -1382,7 +1387,7 @@ var PlaywrightBrowser = class extends EventEmitter3 {
|
|
|
1382
1387
|
throw new Error(`Invalid playwright browser parameter`);
|
|
1383
1388
|
}
|
|
1384
1389
|
super();
|
|
1385
|
-
const { closeFreePagesIntervalSeconds =
|
|
1390
|
+
const { closeFreePagesIntervalSeconds = 300, maxPageFreeSeconds = 900, headless = false, executablePath = "" } = options;
|
|
1386
1391
|
this.#browser = browser;
|
|
1387
1392
|
this.#browserIdx = browserIdx;
|
|
1388
1393
|
this.#lsdBrowserContexts = [];
|
|
@@ -2842,7 +2847,7 @@ var PuppeteerBrowser = class extends EventEmitter6 {
|
|
|
2842
2847
|
return this.#options.maxPagesPerBrowserContext ? this.#options.maxPagesPerBrowserContext : 20;
|
|
2843
2848
|
}
|
|
2844
2849
|
#maxPageFreeSeconds() {
|
|
2845
|
-
return this.#options.maxPageFreeSeconds ? this.#options.maxPageFreeSeconds :
|
|
2850
|
+
return this.#options.maxPageFreeSeconds ? this.#options.maxPageFreeSeconds : 900;
|
|
2846
2851
|
}
|
|
2847
2852
|
#userAgent() {
|
|
2848
2853
|
return this.#options.userAgent ? this.#options.userAgent : "";
|
|
@@ -2853,7 +2858,7 @@ var PuppeteerBrowser = class extends EventEmitter6 {
|
|
|
2853
2858
|
throw new Error(`Invalid puppeteer browser parameter`);
|
|
2854
2859
|
}
|
|
2855
2860
|
super();
|
|
2856
|
-
const { closeFreePagesIntervalSeconds =
|
|
2861
|
+
const { closeFreePagesIntervalSeconds = 300, maxPageFreeSeconds = 900, headless = false, executablePath = "" } = options;
|
|
2857
2862
|
this.#browser = browser;
|
|
2858
2863
|
this.#browserIdx = browserIdx;
|
|
2859
2864
|
this.#lsdBrowserContexts = [];
|
package/package.json
CHANGED