feat: add mode param options
This commit is contained in:
@@ -37,6 +37,7 @@ declare global {
|
|||||||
* Defines optional intepreter options (passed in constructor)
|
* Defines optional intepreter options (passed in constructor)
|
||||||
*/
|
*/
|
||||||
interface InterpreterOptions {
|
interface InterpreterOptions {
|
||||||
|
mode?: string;
|
||||||
maxRepeats: number;
|
maxRepeats: number;
|
||||||
maxConcurrency: number;
|
maxConcurrency: number;
|
||||||
serializableCallback: (output: any) => (void | Promise<void>);
|
serializableCallback: (output: any) => (void | Promise<void>);
|
||||||
@@ -433,6 +434,11 @@ export default class Interpreter extends EventEmitter {
|
|||||||
this.options.debugChannel.setActionType('scrapeSchema');
|
this.options.debugChannel.setActionType('scrapeSchema');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.options.mode && this.options.mode === 'editor') {
|
||||||
|
await this.options.serializableCallback({});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
await this.ensureScriptsLoaded(page);
|
await this.ensureScriptsLoaded(page);
|
||||||
|
|
||||||
const scrapeResult = await page.evaluate((schemaObj) => window.scrapeSchema(schemaObj), schema);
|
const scrapeResult = await page.evaluate((schemaObj) => window.scrapeSchema(schemaObj), schema);
|
||||||
@@ -463,6 +469,11 @@ export default class Interpreter extends EventEmitter {
|
|||||||
this.options.debugChannel.setActionType('scrapeList');
|
this.options.debugChannel.setActionType('scrapeList');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.options.mode && this.options.mode === 'editor') {
|
||||||
|
await this.options.serializableCallback({});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
await this.ensureScriptsLoaded(page);
|
await this.ensureScriptsLoaded(page);
|
||||||
if (!config.pagination) {
|
if (!config.pagination) {
|
||||||
const scrapeResults: Record<string, any>[] = await page.evaluate((cfg) => window.scrapeList(cfg), config);
|
const scrapeResults: Record<string, any>[] = await page.evaluate((cfg) => window.scrapeList(cfg), config);
|
||||||
|
|||||||
Reference in New Issue
Block a user