【发布时间】:2020-05-10 18:18:52
【问题描述】:
我正在尝试使用代理通过 puppeteer 浏览 google.com,但 Chromium 似乎阻止了我。
代码示例:
const puppeteer = require('puppeteer');
(async() => {
const proxyUrl = 'http://gate.smartproxy.com:7000';
const username = 'xxxxx';
const password = 'xxxxx';
const browser = await puppeteer.launch({
args: [`--proxy-server=${proxyUrl}`],
headless: false,
});
const page = await browser.newPage();
await page.authenticate({ username, password });
await page.goto('https://google.com/');
const html = await page.$eval('body', e => e.innerHTML);
console.log(html);
await browser.close();
})();
错误:
(node:6673) UnhandledPromiseRejectionWarning: Error: net::ERR_TUNNEL_CONNECTION_FAILED at https://google.com/...
我已经在代理端进行了检查,它们正在工作。
如果使用 puppeteer 无法实现(因为他们使用的是 Chromium),您对如何使用代理浏览 Google 有其他想法吗?
谢谢,
【问题讨论】:
标签: node.js web-scraping puppeteer