User agent randomized
This commit is contained in:
parent
b97b10975d
commit
affb54155c
@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"puppeteer": "^14.4.0"
|
"puppeteer": "~19.5.2",
|
||||||
|
"user-agents": "~1.0.1260"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,15 @@
|
|||||||
// 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'});
|
||||||
|
|
||||||
const html = await page.content();
|
const html = await page.content();
|
||||||
|
Reference in New Issue
Block a user