diff --git a/maxun-core/src/interpret.ts b/maxun-core/src/interpret.ts index 506c7bd7..32885c63 100644 --- a/maxun-core/src/interpret.ts +++ b/maxun-core/src/interpret.ts @@ -291,12 +291,22 @@ export default class Interpreter extends EventEmitter { await this.options.serializableCallback(scrapeResult); }, - scrapeList: async (config: { listSelector: string, fields: any, limit?: number, flexible?: boolean }) => { + scrapeList: async (config: { listSelector: string, fields: any, limit?: number, flexible?: boolean, pagination:any }) => { await this.ensureScriptsLoaded(page); const scrapeResults: Record[] = await page.evaluate((cfg) => window.scrapeList(cfg), config); await this.options.serializableCallback(scrapeResults); }, + scrapeListAuto: async (config: { listSelector: string }) => { + await this.ensureScriptsLoaded(page); + + const scrapeResults: { selector: string, innerText: string }[] = await page.evaluate((listSelector) => { + return window.scrapeListAuto(listSelector); + }, config.listSelector); + + await this.options.serializableCallback(scrapeResults); + }, + scroll: async (pages?: number) => { await page.evaluate(async (pagesInternal) => { for (let i = 1; i <= (pagesInternal ?? 1); i += 1) { @@ -417,7 +427,7 @@ export default class Interpreter extends EventEmitter { } private async ensureScriptsLoaded(page: Page) { - const isScriptLoaded = await page.evaluate(() => typeof window.scrape === 'function' && typeof window.scrapeSchema === 'function' && typeof window.scrapeList === 'function'); + const isScriptLoaded = await page.evaluate(() => typeof window.scrape === 'function' && typeof window.scrapeSchema === 'function' && typeof window.scrapeList === 'function' && typeof window.scrapeListAuto === 'function'); if (!isScriptLoaded) { await page.addInitScript({ path: path.join(__dirname, 'browserSide', 'scraper.js') }); }