Take screenshot before modifying HTML

Otherwise the screenshot will be very messed up
This commit is contained in:
aularon 2020-01-03 11:12:40 +02:00 committed by GitHub
parent d362e4ae2c
commit 77c1bb8372
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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