Puppeteer中使用Stealth.min.js库

这里需要安装npm install puppeteer-extra puppeteer-extra-plugin-stealth,然后,在启动浏览器时,Puppeteer 会自动应用 Stealth.min.js 插件的功能。

const puppeteer = require('puppeteer-extra');
const StealthPlugin = require('puppeteer-extra-plugin-stealth');

async function removeBrowserFeatures() {
  puppeteer.use(StealthPlugin());

  const browser = await puppeteer.launch();
  const page = await browser.newPage();

  await page.goto('https://example.com');

  // 执行其他操作...

  await browser.close();
}

removeBrowserFeatures();

你可能感兴趣的:(Node.js,javascript,开发语言,ecmascript)