For the complete documentation index, see llms.txt. This page is also available as Markdown.

Puppeteer

Puppeteer 需要两件事:启动时加 --proxy-server,再用 page.authenticate() 处理凭证。

基础写法

import puppeteer from "puppeteer";

const browser = await puppeteer.launch({
  args: ["--proxy-server=http://gate.helodata.io:7777"],
});
const page = await browser.newPage();

await page.authenticate({
  username: "helo_s1a2b3c4d5e-type-res-region-us",
  password: "PASSWORD",
});

await page.goto("https://ipv4.icanhazip.com");
console.log(await page.content());
await browser.close();

page.authenticate() 透明处理代理认证弹框。

ISP

puppeteer-page-proxy 按页代理

官方 Puppeteer 无法运行中改代理——Chromium 启动后 --proxy-server 就固定了。要按页轮换,请用 puppeteer-page-proxy

useProxy() 可反复调用,在请求间切换 page 的代理。

ISP 轮换示例

验证

常见陷阱

  • page.goto() 之前没调用 authenticate() — 首个请求会卡在认证弹框。newPage() 后立刻调用。

  • puppeteer-extra-plugin-stealth 只伪装浏览器指纹,不改 IP——配合 helodata 才能两手都硬。

  • 仅用 --proxy-server 导致所有页共用代理 — 按页代理需上述插件。

最后更新于

这有帮助吗?