Skip to content

Commit

Permalink
fix: added UserAgent to prevent Captchas (hopefully)
Browse files Browse the repository at this point in the history
  • Loading branch information
Disane87 committed Oct 31, 2024
1 parent fc34b3c commit 9acf77d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/classes/scrape-command.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ export abstract class ScrapeCommand<
}

public async newPage(): Promise<Page> {
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) {
Expand Down
1 change: 1 addition & 0 deletions src/commands/scrape/amazon/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export default class Amazon extends ScrapeCommand<typeof Amazon> {
public async run(): Promise<void> {
this.options = this.flags;
await this.handleOnlyNewOption();

this.logger.debug(`Options: ${JSON.stringify(this.options, null, 4)}`);
this.currentPage = await this.newPage();

Expand Down

0 comments on commit 9acf77d

Please sign in to comment.