Puppeteerのプロキシ連携
Puppeteer sets the proxy as a Chromium launch argument, then supplies the username and password through page.authenticate(). This two-step pattern is the idiomatic way to run authenticated proxies in headless Chrome, and it works the same in headful mode for debugging.
import puppeteer from "puppeteer";
// Residential gateway, or "--proxy-server=http://IP:PORT" for one of your ISP proxies.
const browser = await puppeteer.launch({
args: ["--proxy-server=http://gw-eu.murphyproxies.com:8888"],
});
const page = await browser.newPage();
// Chrome takes the credentials here, not on the launch argument.
await page.authenticate({
username: "USERNAME",
password: "PASSWORD",
});
await page.goto("https://httpbin.org/ip", { waitUntil: "networkidle0" });
console.log(await page.evaluate(() => document.body.innerText));
await browser.close();5ステップで設定
- 1Install the client with npm install puppeteer.
- 2Pass --proxy-server=http://gw-eu.murphyproxies.com:8888 in the launch args (another gw- region, port 7777 on Private 2, or http://IP:PORT for an ISP proxy).
- 3Call page.authenticate() with the username and password from your dashboard before navigating.
- 4Navigate with waitUntil set to networkidle0 so the page settles before you read it.
- 5Evaluate document.body.innerText on an IP echo page to confirm the exit IP.
Puppeteerのプロキシに関する質問
認証からローテーションまで、PuppeteerをMurphy経由で使うためのポイントをまとめました。
The host and port go in the --proxy-server launch argument, but the username and password go through page.authenticate() on each page. Chromium will not accept credentials embedded in the launch flag, so this split is required.
Call page.authenticate() once per page object before its first navigation. If you open several pages in the same browser, authenticate each one, or route your work through a single page to keep it simple.
Chromium supports SOCKS5 via --proxy-server=socks5://HOST:PORT, but it does not support SOCKS5 username and password authentication. For authenticated Murphy proxies with Puppeteer, use the HTTP scheme with page.authenticate() as shown.
Puppeteer用の認証情報を取得
ターゲットに合ったネットワークを選びましょう。高速で安定したセッションにはISPプロキシ、厳しいボット対策には幅広いIPを持つレジデンシャルプロキシ。