From 9acf77d131d57dc80ff58cf86750278b4928cec2 Mon Sep 17 00:00:00 2001 From: Marco Franke Date: Thu, 31 Oct 2024 10:37:09 +0100 Subject: [PATCH] fix: added UserAgent to prevent Captchas (hopefully) --- src/classes/scrape-command.class.ts | 4 +++- src/commands/scrape/amazon/index.ts | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/classes/scrape-command.class.ts b/src/classes/scrape-command.class.ts index fdd06dd0..06137f05 100644 --- a/src/classes/scrape-command.class.ts +++ b/src/classes/scrape-command.class.ts @@ -96,7 +96,9 @@ export abstract class ScrapeCommand< } public async newPage(): Promise { - return await this.browser.newPage(); + const page = await this.browser.newPage(); + page.setUserAgent('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36'); + return page; } async getActivePage(timeout: number = 500) { diff --git a/src/commands/scrape/amazon/index.ts b/src/commands/scrape/amazon/index.ts index 51b32e50..bf55312d 100644 --- a/src/commands/scrape/amazon/index.ts +++ b/src/commands/scrape/amazon/index.ts @@ -42,6 +42,7 @@ export default class Amazon extends ScrapeCommand { public async run(): Promise { this.options = this.flags; await this.handleOnlyNewOption(); + this.logger.debug(`Options: ${JSON.stringify(this.options, null, 4)}`); this.currentPage = await this.newPage();