无头木偶与无头木偶之间的不同行为

时间:2019-03-13 23:22:49

标签: node.js web-scraping puppeteer

在adidas.com上,以下代码以无头但非头的形式返回403,是的,我知道这已经被问过了,以前没有解决方案。

resolve((async (url) => {
  let browser = await puppeteer.launch({
    headless: false,
    args: ["--no-sandbox", "--enable-features=NetworkService", "--ignore-certificate-errors"]
  });
  let page = await browser.newPage();
  await page.goto(url, {waitUntil: 'networkidle2'});
  await page.setUserAgent('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.75 Safari/537.36');
  let body = await page.evaluate(() => document.documentElement.outerHTML);
  await browser.close();
  return body;
})(url))

0 个答案:

没有答案