From 77c1bb83725c5e20301ecca8db271787c8e1b368 Mon Sep 17 00:00:00 2001 From: aularon Date: Fri, 3 Jan 2020 11:12:40 +0200 Subject: [PATCH] Take screenshot before modifying HTML Otherwise the screenshot will be very messed up --- src/modules/se_scraper.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/modules/se_scraper.js b/src/modules/se_scraper.js index d4f64c9..0d574d8 100644 --- a/src/modules/se_scraper.js +++ b/src/modules/se_scraper.js @@ -190,6 +190,13 @@ module.exports = class Scraper { let parsed = this.parse(html); this.results[keyword][this.page_num] = parsed ? parsed : await this.parse_async(html); + if (this.config.screen_output) { + this.results[keyword][this.page_num].screenshot = await this.page.screenshot({ + encoding: 'base64', + fullPage: false, + }); + } + if (this.config.html_output) { if (this.config.clean_html_output) { @@ -236,13 +243,6 @@ module.exports = class Scraper { this.results[keyword][this.page_num].html = html_contents; } - if (this.config.screen_output) { - this.results[keyword][this.page_num].screenshot = await this.page.screenshot({ - encoding: 'base64', - fullPage: false, - }); - } - this.page_num += 1; // only load the next page when we will pass the next iteration