Proxy 如何使用Puppeter docker加载自己的自定义代理列表

Proxy 如何使用Puppeter docker加载自己的自定义代理列表,proxy,puppeteer,Proxy,Puppeteer,我不喜欢使用tor,所以我有自己的私有代理,可以用来抓取amazon。 现在使用tor classic方法,我知道如何: `--proxy-server=socks5://209.205.212.34:${1235}`] : ['--no-sandbox'], 但是我创建了我自己的proxies.txt,我想在docker中随机化它 我的代码不起作用: const puppeteer = require('puppeteer-extra'); const stealthPlugin = req

我不喜欢使用tor,所以我有自己的私有代理,可以用来抓取amazon。 现在使用tor classic方法,我知道如何:

`--proxy-server=socks5://209.205.212.34:${1235}`] : ['--no-sandbox'],
但是我创建了我自己的proxies.txt,我想在docker中随机化它

我的代码不起作用:

const puppeteer = require('puppeteer-extra');
const stealthPlugin = require('puppeteer-extra-plugin-stealth');
const { IS_PROD } = require('../utils/constants');
const proxyIP = require('../core/proxies.txt');

puppeteer.use(stealthPlugin());

// In order to run chromium processes in parallel. https://github.com/puppeteer/puppeteer/issues/594#issuecomment-325919885
process.setMaxListeners(Infinity);
const getBrowserInstance = async => {
  const browser = await puppeteer.launch({
    headless: false,
    const randomIP = proxyIP[Math.floor(Math.random() * proxyIP.length)];
    
    args: IS_PROD ? ['--headless', '--user-agent=Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4486.0 Safari/537.36', '--no-sandbox', `--proxy-server=socks5://${randomIP}`] : ['--no-sandbox'],
    devtools: !IS_PROD,
    executablePath: IS_PROD ? '/usr/bin/chromium-browser' : undefined,
  });
  const incognitoBrowserContext = browser.createIncognitoBrowserContext();
  incognitoBrowserContext.close = browser.close;
  return incognitoBrowserContext;
  
};

module.exports = {
  getBrowserInstance,
};