From 9cc3e856f5bd961350da1f1154d9b54a95a2bbb6 Mon Sep 17 00:00:00 2001 From: JakubDrobnik Date: Mon, 19 Nov 2018 18:17:17 +0100 Subject: [PATCH] Added longer waiting timeout + live view --- src/main.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main.js b/src/main.js index 8272626..96296c4 100644 --- a/src/main.js +++ b/src/main.js @@ -6,6 +6,8 @@ const Apify = require('apify'); const { sleep } = Apify.utils; const { injectJQuery } = Apify.utils.puppeteer; +const DEFAULT_TIMEOUT = 60 * 1000; // 60 sec + const sleepPromised = ms => new Promise(resolve => setTimeout(resolve, ms)); const logError = (msg, e) => { @@ -151,6 +153,7 @@ Apify.main(async () => { launchPuppeteerOptions: { useApifyProxy: true, apifyProxyGroups: ['CZECH_LUMINATI'], + liveView: true, }, requestQueue, handlePageTimeoutSecs: 1200, @@ -163,7 +166,7 @@ Apify.main(async () => { await page.click('#searchbox-searchbutton'); await sleep(5000); while(true) { - await page.waitForSelector('#section-pagination-button-next'); + await page.waitForSelector('#section-pagination-button-next', { timeout: DEFAULT_TIMEOUT }); await enqueueAllUrlsFromPagination(page, requestQueue); const nextButton = await page.$('#section-pagination-button-next'); const isNextPagination = (await nextButton.getProperty('disabled') === 'true'); @@ -178,7 +181,7 @@ Apify.main(async () => { } else { // Get data from review await injectJQuery(page); - await page.waitForSelector('h1.section-hero-header-title'); + await page.waitForSelector('h1.section-hero-header-title', { timeout: DEFAULT_TIMEOUT }); const placeDetail = await page.evaluate(() => { return { title: $('h1.section-hero-header-title').text().trim(),