Open tor browser with selenium

后端 未结 10 1110
长发绾君心
长发绾君心 2020-12-02 09:15

Is it possible to make selenium use the TOR browser? Does anyone have any code they could copy-paste?

10条回答
  •  萌比男神i
    2020-12-02 09:55

    I looked into this, and unless I'm mistaken, on face value it's not possible.

    The reason this cannot be done is because:

    • Tor Browser is based on the Firefox code.
    • Tor Browser has specific patches to the Firefox code to prevent external applications communicating with the Tor Browser (including blocking the Components.Interfaces library).
    • The Selenium Firefox WebDriver communicates with the browser through Javascript libraries that are, as aforementioned, blocked by Tor Browser.

    This is presumably so no-one outside of the Tor Browser either on your box or over the internet knows about your browsing.

    Your alternatives are:

    • Use a Tor proxy through Firefox instead of the Tor Browser (see the link in the comments of the question).
    • Rebuild the Firefox source code with the Tor Browser patches excluding those that prevent external communication with Tor Browser.

    I suggest the former.

提交回复
热议问题