User agent randomized

This commit is contained in:
Profitroll 2023-01-14 13:24:44 +01:00
parent b97b10975d
commit affb54155c
2 changed files with 5 additions and 2 deletions

View File

@ -1,5 +1,6 @@
{ {
"dependencies": { "dependencies": {
"puppeteer": "^14.4.0" "puppeteer": "~19.5.2",
"user-agents": "~1.0.1260"
} }
} }

View File

@ -1,12 +1,14 @@
// npm install https://github.com/GoogleChrome/puppeteer/ // npm install https://github.com/GoogleChrome/puppeteer/
const puppeteer = require('puppeteer'); const puppeteer = require('puppeteer');
const userAgent = require('user-agents');
(async () => { (async () => {
const url = process.argv[2]; const url = process.argv[2];
const browser = await puppeteer.launch(); const browser = await puppeteer.launch();
const page = await browser.newPage(); const page = await browser.newPage();
await page.setUserAgent(userAgent.random().toString());
await page.goto(url, {waitUntil: 'load'}); await page.goto(url, {waitUntil: 'load'});