Puppeteer 代理与亮数据集成

了解如何进行你的 Puppeteer 代理设置并与亮数据的代理 IP集成

Puppeteer是一个 Node 库,通过利用其高级 API 控制无头和非无头Chrome 和 Chromium。  

亮数据超级代理和 Puppeteer 集成

  • Begin by going to your Bright Data Dashboard and clicking ‘create a Zone’.
  • Choose ‘Network type’ and click save.
  • Within Puppeteer fill in the ‘Proxy IP:Port’ in the ‘proxy-server’ value, for examplezproxy.lum-superproxy.io:22225.
  • Under ‘page.authenticate’ input your Bright Data account ID and proxy Zone name in the ‘username’ value, for example:lum-customer-CUSTOMER-zone-YOURZONE and your Zone password found in the Zone settings.
  • For example:
const puppeteer = require('puppeteer');

(async () => {
  const browser = await puppeteer.launch({
    headless: false,
    args: ['--proxy-server=zproxy.lum-superproxy.io:22225']
  });
  const page = await browser.newPage();
    await page.authenticate({
        username: 'lum-customer-USERNAME-zone-YOURZONE',
        password: 'PASSWORD'
    });
    await page.goto('http://lumtest.com/myip.json');
    await page.screenshot({path: 'example.png'});
    await browser.close();
})();

代理管理器和 Puppeteer 集成

  • Create a Zone with the network, IP type, and number of IPs you wish to use.
  • Install the Proxy Manager.
  • Click ‘add new proxy’ and choose the Zone and settings you require, click ‘save’.
  • In Puppeteer, under the ‘proxy-server’, input your local IP and Proxy Manager port (i.e. 127.0.0.1:24000)
    • The local host IP is 127.0.0.1
    • The port created in the Proxy Manager is 24XXX, for example, 24000
  • Leave the username and password values empty, as the Bright Data Proxy Manager has already been authenticated with the Super Proxy.
  • For example:
const puppeteer = require('puppeteer');

(async () => {
    const browser = await puppeteer.launch({
        headless: false,
        args: ['--proxy-server=127.0.0.1:24000']
    });
    const page = await browser.newPage();
    await page.authenticate();
    await page.goto('http://lumtest.com/myip.json');
    await page.screenshot({path: 'example.png'});
    await browser.close();
})();

Dataset Sample Request

电话咨询