|
|
|
@ -46,10 +46,13 @@ class PuppeteerBrowser extends Browser {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async visit(url) {
|
|
|
|
|
try {
|
|
|
|
|
const browser = await this.browser();
|
|
|
|
|
|
|
|
|
|
const page = await browser.newPage();
|
|
|
|
|
|
|
|
|
|
page.setDefaultTimeout(this.options.maxWait);
|
|
|
|
|
|
|
|
|
|
await page.setRequestInterception(true);
|
|
|
|
|
|
|
|
|
|
page.on('request', request => request.continue());
|
|
|
|
@ -78,12 +81,8 @@ class PuppeteerBrowser extends Browser {
|
|
|
|
|
|
|
|
|
|
await page.setUserAgent(this.options.userAgent);
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
await Promise.race([
|
|
|
|
|
page.goto(url, {
|
|
|
|
|
timeout: this.options.maxWait,
|
|
|
|
|
waitUntil: 'networkidle2',
|
|
|
|
|
}),
|
|
|
|
|
page.goto(url, { waitUntil: 'networkidle2' }),
|
|
|
|
|
new Promise(resolve => setTimeout(resolve, this.options.maxWait)),
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
@ -117,13 +116,11 @@ class PuppeteerBrowser extends Browser {
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
this.html = await page.content();
|
|
|
|
|
|
|
|
|
|
await page.close();
|
|
|
|
|
} catch (error) {
|
|
|
|
|
throw new Error(error.toString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await page.close();
|
|
|
|
|
|
|
|
|
|
this.page = null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|