【问题标题】:Launch Tor browser using Puppeteer instead of Chrome on Windows 10在 Windows 10 上使用 Puppeteer 而不是 Chrome 启动 Tor 浏览器
【发布时间】:2022-06-29 01:53:30
【问题描述】:

我在 Windows 10 机器上,我已经下载了 Tor 浏览器,并且使用 Tor 浏览器通常可以正常工作,但我想让 Puppeteer 使用 Tor 以无头模式启动,我看到了很多关于 Socks5 代理的信息,但不知道如何设置它以及为什么它不起作用?大概是在运行启动方法时,它会在后台启动 Tor?

到目前为止,这是我在节点中的 JS 代码...

// puppeteer-extra is a drop-in replacement for puppeteer,
// it augments the installed puppeteer with plugin functionality
const puppeteer = require('puppeteer-extra')

// add stealth plugin and use defaults (all evasion techniques)
const StealthPlugin = require('puppeteer-extra-plugin-stealth')
puppeteer.use(StealthPlugin())

// artificial sleep function
const sleep = async (ms) => {
  return new Promise((res, rej) => {
    setTimeout(() => {
      res()
    }, ms)
  })
}

// login function
const emulate = async () => {

  // initiate a Puppeteer instance with options and launch
  const browser = await puppeteer.launch({
    headless: false,
    args: [
      '--proxy-server=socks5://127.0.0.1:1337'
    ]
  });

  // launch Facebook and wait until idle
  const page = await browser.newPage()

  // go to Tor
  await page.goto('https://check.torproject.org/');

  const isUsingTor = await page.$eval('body', el =>
     el.innerHTML.includes('Congratulations. This browser is configured to use Tor')
    );

    if (!isUsingTor) {
        console.log('Not using Tor. Closing...')
        return await browser.close()
    }


  // do something...

}

// kick it off
emulate()

这给了我一个 ERR_PROXY_CONNECTION_FAILED 铬错误,为什么不使用 Tor 启动?

【问题讨论】:

  • 来自the home page for Puppeteer:“Puppeteer 是一个 Node 库,它提供了一个高级 API 来通过 DevTools 协议控制无头 Chrome 或 Chromium。它也可以配置为使用完整(非无头)铬或铬。”与 Tor 浏览器无关。除了 Chrome 或 Chromium 之外,没有关于任何浏览器的信息……不确定您在寻找什么。另见Can I use this for other browsers? #1667
  • --proxy-server=socks5://127.0.0.1:1337 之类的东西是我想要实现的,我看到有人在网上使用它,但它对我不起作用。

标签: javascript node.js puppeteer tor


【解决方案1】:

您需要采取更多步骤。

  1. 您需要在系统上安装 tor。您可能想使用- brew install tor
  2. 用-启动tor brew 服务启动 tor
  3. 默认使用9050端口,所以你的代理应该是这样的; --proxy-server=socks5://127.0.0.1:9050 如果必须使用其他端口,则必须将其添加到 torrc 文件中。 此外,您可能需要在您的 //launch facebook///
  4. 之前执行 //go to totor//

【讨论】:

    猜你喜欢
    • 2013-06-11
    • 2021-06-18
    • 2021-04-23
    • 1970-01-01
    • 2020-10-02
    • 2018-10-31
    • 2017-01-01
    • 1970-01-01
    • 2016-12-27
    相关资源
    最近更新 更多