@letsscrapedata/controller 0.0.70 → 0.1.0
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 +175 -46
- package/dist/index.d.cts +27 -3
- package/dist/index.d.ts +27 -3
- package/dist/index.js +173 -44
- package/package.json +7 -12
package/dist/index.d.cts
CHANGED
|
@@ -20,7 +20,7 @@ type CheerioNode = cheerio.Cheerio;
|
|
|
20
20
|
type BrowserCreationMethod = "launch" | "connect";
|
|
21
21
|
type BrowserContextCreationMethod = "launch" | "new";
|
|
22
22
|
type BrowserContextStatus = "free" | "busy" | "closed";
|
|
23
|
-
type LsdBrowserType = "chromium" | "firefox" | "webkit";
|
|
23
|
+
type LsdBrowserType = "chrome" | "chromium" | "firefox" | "webkit";
|
|
24
24
|
/**
|
|
25
25
|
* events emittd by controllers, such as playwright
|
|
26
26
|
*/
|
|
@@ -127,11 +127,13 @@ interface LsdApiContext {
|
|
|
127
127
|
destroy(): Promise<boolean>;
|
|
128
128
|
}
|
|
129
129
|
interface PlaywrightBrowserTypes {
|
|
130
|
+
chrome: BrowserType;
|
|
130
131
|
chromium: BrowserType;
|
|
131
132
|
firefox: BrowserType;
|
|
132
133
|
webkit: BrowserType;
|
|
133
134
|
}
|
|
134
135
|
interface PatchrightBrowserTypes {
|
|
136
|
+
chrome: BrowserType;
|
|
135
137
|
chromium: BrowserType$1;
|
|
136
138
|
firefox: BrowserType$1;
|
|
137
139
|
webkit: BrowserType$1;
|
|
@@ -180,6 +182,9 @@ interface BrowserOptions {
|
|
|
180
182
|
type BrowserLaunchMethod = "launch" | "launchServer";
|
|
181
183
|
interface LsdLaunchOptions extends BrowserOptions {
|
|
182
184
|
args?: string[];
|
|
185
|
+
/**
|
|
186
|
+
* executablePath is required to launch chrome
|
|
187
|
+
*/
|
|
183
188
|
executablePath?: string;
|
|
184
189
|
/**
|
|
185
190
|
* @default true
|
|
@@ -208,6 +213,13 @@ interface LsdLaunchOptions extends BrowserOptions {
|
|
|
208
213
|
* * puppeteer creates a default/new browserContext during launching browser
|
|
209
214
|
*/
|
|
210
215
|
userAgent?: string;
|
|
216
|
+
/**
|
|
217
|
+
* only valid when !userAgent && headerless && !headlessUserAgent
|
|
218
|
+
*/
|
|
219
|
+
headlessUserAgent?: string;
|
|
220
|
+
/**
|
|
221
|
+
* if userDataDir is not "" (or undefined) and browserControllerType is "playwright" / "patchwright", then launch
|
|
222
|
+
*/
|
|
211
223
|
userDataDir?: string;
|
|
212
224
|
/**
|
|
213
225
|
* @default "launch"
|
|
@@ -692,6 +704,10 @@ interface ResponseInterceptionItem {
|
|
|
692
704
|
* request.postData()
|
|
693
705
|
*/
|
|
694
706
|
requestData: string;
|
|
707
|
+
/**
|
|
708
|
+
* request.resourceType()
|
|
709
|
+
*/
|
|
710
|
+
resourceType: string;
|
|
695
711
|
/**
|
|
696
712
|
* response.text()
|
|
697
713
|
*/
|
|
@@ -1145,6 +1161,7 @@ interface LsdPage extends EventEmitter {
|
|
|
1145
1161
|
* start to use this free page
|
|
1146
1162
|
*/
|
|
1147
1163
|
use(): boolean;
|
|
1164
|
+
userAgent(): string;
|
|
1148
1165
|
/**
|
|
1149
1166
|
*
|
|
1150
1167
|
* @param selector CSS selector, not XPath
|
|
@@ -1160,8 +1177,9 @@ interface LsdPage extends EventEmitter {
|
|
|
1160
1177
|
* obj=window?.[key1]...?.[keyn]
|
|
1161
1178
|
* @return obj ? JSON.stringify(obj) : ""
|
|
1162
1179
|
* @param keys
|
|
1180
|
+
* @param isolated default true; whether to run in isolated context; only valid for patchwright(TBD: and camoufox)
|
|
1163
1181
|
*/
|
|
1164
|
-
windowMember(keys: string[]): Promise<string>;
|
|
1182
|
+
windowMember(keys: string[], isolated?: boolean): Promise<string>;
|
|
1165
1183
|
_origPage(): AllPage;
|
|
1166
1184
|
}
|
|
1167
1185
|
interface LsdBrowserContext extends EventEmitter {
|
|
@@ -1216,6 +1234,7 @@ interface LsdBrowserContext extends EventEmitter {
|
|
|
1216
1234
|
* start to use this LsdBrowserContext
|
|
1217
1235
|
*/
|
|
1218
1236
|
use(): boolean;
|
|
1237
|
+
userAgent(): string;
|
|
1219
1238
|
_origBrowserContext(): AllBrowserContext;
|
|
1220
1239
|
}
|
|
1221
1240
|
interface LsdBrowser extends EventEmitter {
|
|
@@ -1328,7 +1347,7 @@ declare class PlaywrightBrowser extends EventEmitter implements LsdBrowser {
|
|
|
1328
1347
|
|
|
1329
1348
|
declare class PlaywrightBrowserContext extends EventEmitter implements LsdBrowserContext {
|
|
1330
1349
|
#private;
|
|
1331
|
-
constructor(lsdBrowser: LsdBrowser, browserContext: BrowserContext, browserContextCreationMethod: BrowserContextCreationMethod, incognito?: boolean, proxy?: ProxyInController | null, browserIdx?: number, browserContextIdx?: number, maxPagesPerBrowserContext?: number, maxPageFreeSeconds?: number, maxViewportOfNewPage?: boolean);
|
|
1350
|
+
constructor(lsdBrowser: LsdBrowser, browserContext: BrowserContext, browserContextCreationMethod: BrowserContextCreationMethod, incognito?: boolean, proxy?: ProxyInController | null, browserIdx?: number, browserContextIdx?: number, maxPagesPerBrowserContext?: number, maxPageFreeSeconds?: number, userAgent?: string, maxViewportOfNewPage?: boolean);
|
|
1332
1351
|
apiContext(): LsdApiContext;
|
|
1333
1352
|
browser(): LsdBrowser;
|
|
1334
1353
|
close(): Promise<boolean>;
|
|
@@ -1347,6 +1366,7 @@ declare class PlaywrightBrowserContext extends EventEmitter implements LsdBrowse
|
|
|
1347
1366
|
setStateData(stateData: BrowserStateData): Promise<boolean>;
|
|
1348
1367
|
status(): BrowserContextStatus;
|
|
1349
1368
|
use(): boolean;
|
|
1369
|
+
userAgent(): string;
|
|
1350
1370
|
_origBrowserContext(): AllBrowserContext;
|
|
1351
1371
|
}
|
|
1352
1372
|
|
|
@@ -1409,6 +1429,7 @@ declare class PlaywrightPage extends EventEmitter implements LsdPage {
|
|
|
1409
1429
|
title(): Promise<string>;
|
|
1410
1430
|
url(): string;
|
|
1411
1431
|
use(): boolean;
|
|
1432
|
+
userAgent(): string;
|
|
1412
1433
|
waitForElement(selector: string, options?: WaitElementOptions): Promise<boolean>;
|
|
1413
1434
|
waitForNavigation(options: WaitNavigationOptions): Promise<boolean>;
|
|
1414
1435
|
windowMember(keys: string[]): Promise<string>;
|
|
@@ -1495,6 +1516,7 @@ declare class PuppeteerBrowserContext extends EventEmitter implements LsdBrowser
|
|
|
1495
1516
|
setStateData(stateData: BrowserStateData): Promise<boolean>;
|
|
1496
1517
|
status(): BrowserContextStatus;
|
|
1497
1518
|
use(): boolean;
|
|
1519
|
+
userAgent(): string;
|
|
1498
1520
|
_origBrowserContext(): AllBrowserContext;
|
|
1499
1521
|
}
|
|
1500
1522
|
|
|
@@ -1557,6 +1579,7 @@ declare class PuppeteerPage extends EventEmitter implements LsdPage {
|
|
|
1557
1579
|
title(): Promise<string>;
|
|
1558
1580
|
url(): string;
|
|
1559
1581
|
use(): boolean;
|
|
1582
|
+
userAgent(): string;
|
|
1560
1583
|
waitForElement(selector: string, options?: WaitElementOptions): Promise<boolean>;
|
|
1561
1584
|
waitForNavigation(options: WaitNavigationOptions): Promise<boolean>;
|
|
1562
1585
|
windowMember(keys: string[]): Promise<string>;
|
|
@@ -1662,6 +1685,7 @@ declare class CheerioPage extends EventEmitter implements LsdPage {
|
|
|
1662
1685
|
title(): Promise<string>;
|
|
1663
1686
|
url(): string;
|
|
1664
1687
|
use(): boolean;
|
|
1688
|
+
userAgent(): string;
|
|
1665
1689
|
waitForElement(): Promise<boolean>;
|
|
1666
1690
|
waitForNavigation(): Promise<boolean>;
|
|
1667
1691
|
windowMember(): Promise<string>;
|
package/dist/index.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ type CheerioNode = cheerio.Cheerio;
|
|
|
20
20
|
type BrowserCreationMethod = "launch" | "connect";
|
|
21
21
|
type BrowserContextCreationMethod = "launch" | "new";
|
|
22
22
|
type BrowserContextStatus = "free" | "busy" | "closed";
|
|
23
|
-
type LsdBrowserType = "chromium" | "firefox" | "webkit";
|
|
23
|
+
type LsdBrowserType = "chrome" | "chromium" | "firefox" | "webkit";
|
|
24
24
|
/**
|
|
25
25
|
* events emittd by controllers, such as playwright
|
|
26
26
|
*/
|
|
@@ -127,11 +127,13 @@ interface LsdApiContext {
|
|
|
127
127
|
destroy(): Promise<boolean>;
|
|
128
128
|
}
|
|
129
129
|
interface PlaywrightBrowserTypes {
|
|
130
|
+
chrome: BrowserType;
|
|
130
131
|
chromium: BrowserType;
|
|
131
132
|
firefox: BrowserType;
|
|
132
133
|
webkit: BrowserType;
|
|
133
134
|
}
|
|
134
135
|
interface PatchrightBrowserTypes {
|
|
136
|
+
chrome: BrowserType;
|
|
135
137
|
chromium: BrowserType$1;
|
|
136
138
|
firefox: BrowserType$1;
|
|
137
139
|
webkit: BrowserType$1;
|
|
@@ -180,6 +182,9 @@ interface BrowserOptions {
|
|
|
180
182
|
type BrowserLaunchMethod = "launch" | "launchServer";
|
|
181
183
|
interface LsdLaunchOptions extends BrowserOptions {
|
|
182
184
|
args?: string[];
|
|
185
|
+
/**
|
|
186
|
+
* executablePath is required to launch chrome
|
|
187
|
+
*/
|
|
183
188
|
executablePath?: string;
|
|
184
189
|
/**
|
|
185
190
|
* @default true
|
|
@@ -208,6 +213,13 @@ interface LsdLaunchOptions extends BrowserOptions {
|
|
|
208
213
|
* * puppeteer creates a default/new browserContext during launching browser
|
|
209
214
|
*/
|
|
210
215
|
userAgent?: string;
|
|
216
|
+
/**
|
|
217
|
+
* only valid when !userAgent && headerless && !headlessUserAgent
|
|
218
|
+
*/
|
|
219
|
+
headlessUserAgent?: string;
|
|
220
|
+
/**
|
|
221
|
+
* if userDataDir is not "" (or undefined) and browserControllerType is "playwright" / "patchwright", then launch
|
|
222
|
+
*/
|
|
211
223
|
userDataDir?: string;
|
|
212
224
|
/**
|
|
213
225
|
* @default "launch"
|
|
@@ -692,6 +704,10 @@ interface ResponseInterceptionItem {
|
|
|
692
704
|
* request.postData()
|
|
693
705
|
*/
|
|
694
706
|
requestData: string;
|
|
707
|
+
/**
|
|
708
|
+
* request.resourceType()
|
|
709
|
+
*/
|
|
710
|
+
resourceType: string;
|
|
695
711
|
/**
|
|
696
712
|
* response.text()
|
|
697
713
|
*/
|
|
@@ -1145,6 +1161,7 @@ interface LsdPage extends EventEmitter {
|
|
|
1145
1161
|
* start to use this free page
|
|
1146
1162
|
*/
|
|
1147
1163
|
use(): boolean;
|
|
1164
|
+
userAgent(): string;
|
|
1148
1165
|
/**
|
|
1149
1166
|
*
|
|
1150
1167
|
* @param selector CSS selector, not XPath
|
|
@@ -1160,8 +1177,9 @@ interface LsdPage extends EventEmitter {
|
|
|
1160
1177
|
* obj=window?.[key1]...?.[keyn]
|
|
1161
1178
|
* @return obj ? JSON.stringify(obj) : ""
|
|
1162
1179
|
* @param keys
|
|
1180
|
+
* @param isolated default true; whether to run in isolated context; only valid for patchwright(TBD: and camoufox)
|
|
1163
1181
|
*/
|
|
1164
|
-
windowMember(keys: string[]): Promise<string>;
|
|
1182
|
+
windowMember(keys: string[], isolated?: boolean): Promise<string>;
|
|
1165
1183
|
_origPage(): AllPage;
|
|
1166
1184
|
}
|
|
1167
1185
|
interface LsdBrowserContext extends EventEmitter {
|
|
@@ -1216,6 +1234,7 @@ interface LsdBrowserContext extends EventEmitter {
|
|
|
1216
1234
|
* start to use this LsdBrowserContext
|
|
1217
1235
|
*/
|
|
1218
1236
|
use(): boolean;
|
|
1237
|
+
userAgent(): string;
|
|
1219
1238
|
_origBrowserContext(): AllBrowserContext;
|
|
1220
1239
|
}
|
|
1221
1240
|
interface LsdBrowser extends EventEmitter {
|
|
@@ -1328,7 +1347,7 @@ declare class PlaywrightBrowser extends EventEmitter implements LsdBrowser {
|
|
|
1328
1347
|
|
|
1329
1348
|
declare class PlaywrightBrowserContext extends EventEmitter implements LsdBrowserContext {
|
|
1330
1349
|
#private;
|
|
1331
|
-
constructor(lsdBrowser: LsdBrowser, browserContext: BrowserContext, browserContextCreationMethod: BrowserContextCreationMethod, incognito?: boolean, proxy?: ProxyInController | null, browserIdx?: number, browserContextIdx?: number, maxPagesPerBrowserContext?: number, maxPageFreeSeconds?: number, maxViewportOfNewPage?: boolean);
|
|
1350
|
+
constructor(lsdBrowser: LsdBrowser, browserContext: BrowserContext, browserContextCreationMethod: BrowserContextCreationMethod, incognito?: boolean, proxy?: ProxyInController | null, browserIdx?: number, browserContextIdx?: number, maxPagesPerBrowserContext?: number, maxPageFreeSeconds?: number, userAgent?: string, maxViewportOfNewPage?: boolean);
|
|
1332
1351
|
apiContext(): LsdApiContext;
|
|
1333
1352
|
browser(): LsdBrowser;
|
|
1334
1353
|
close(): Promise<boolean>;
|
|
@@ -1347,6 +1366,7 @@ declare class PlaywrightBrowserContext extends EventEmitter implements LsdBrowse
|
|
|
1347
1366
|
setStateData(stateData: BrowserStateData): Promise<boolean>;
|
|
1348
1367
|
status(): BrowserContextStatus;
|
|
1349
1368
|
use(): boolean;
|
|
1369
|
+
userAgent(): string;
|
|
1350
1370
|
_origBrowserContext(): AllBrowserContext;
|
|
1351
1371
|
}
|
|
1352
1372
|
|
|
@@ -1409,6 +1429,7 @@ declare class PlaywrightPage extends EventEmitter implements LsdPage {
|
|
|
1409
1429
|
title(): Promise<string>;
|
|
1410
1430
|
url(): string;
|
|
1411
1431
|
use(): boolean;
|
|
1432
|
+
userAgent(): string;
|
|
1412
1433
|
waitForElement(selector: string, options?: WaitElementOptions): Promise<boolean>;
|
|
1413
1434
|
waitForNavigation(options: WaitNavigationOptions): Promise<boolean>;
|
|
1414
1435
|
windowMember(keys: string[]): Promise<string>;
|
|
@@ -1495,6 +1516,7 @@ declare class PuppeteerBrowserContext extends EventEmitter implements LsdBrowser
|
|
|
1495
1516
|
setStateData(stateData: BrowserStateData): Promise<boolean>;
|
|
1496
1517
|
status(): BrowserContextStatus;
|
|
1497
1518
|
use(): boolean;
|
|
1519
|
+
userAgent(): string;
|
|
1498
1520
|
_origBrowserContext(): AllBrowserContext;
|
|
1499
1521
|
}
|
|
1500
1522
|
|
|
@@ -1557,6 +1579,7 @@ declare class PuppeteerPage extends EventEmitter implements LsdPage {
|
|
|
1557
1579
|
title(): Promise<string>;
|
|
1558
1580
|
url(): string;
|
|
1559
1581
|
use(): boolean;
|
|
1582
|
+
userAgent(): string;
|
|
1560
1583
|
waitForElement(selector: string, options?: WaitElementOptions): Promise<boolean>;
|
|
1561
1584
|
waitForNavigation(options: WaitNavigationOptions): Promise<boolean>;
|
|
1562
1585
|
windowMember(keys: string[]): Promise<string>;
|
|
@@ -1662,6 +1685,7 @@ declare class CheerioPage extends EventEmitter implements LsdPage {
|
|
|
1662
1685
|
title(): Promise<string>;
|
|
1663
1686
|
url(): string;
|
|
1664
1687
|
use(): boolean;
|
|
1688
|
+
userAgent(): string;
|
|
1665
1689
|
waitForElement(): Promise<boolean>;
|
|
1666
1690
|
waitForNavigation(): Promise<boolean>;
|
|
1667
1691
|
windowMember(): Promise<string>;
|