Add user agent (#19)

Add user agent to try circumventing DDoS protection.
This commit is contained in:
Bread Genie
2021-05-16 19:34:11 +05:30
committed by GitHub
parent 683ee2dbe0
commit ebc7c43984
3 changed files with 53 additions and 2 deletions
+4 -1
View File
@@ -1,9 +1,12 @@
const chromium = require("chrome-aws-lambda");
const puppeteer = require("puppeteer");
const UserAgent = require("user-agents");
const userAgent = new UserAgent();
const scraper = async (url) => {
const browser = await puppeteer.launch({
args: [...chromium.args, "--hide-scrollbars", "--disable-web-security"],
args: [...chromium.args, "--hide-scrollbars", "--disable-web-security", "--user-agent=" + userAgent + ""],
defaultViewport: chromium.defaultViewport,
executablePath: await chromium.executablePath,
headless: true,