Search code examples
pythonwindowsselenium-webdriverselenium-chromedrivertor

How to use tor with selenium-webdriver in python in a windows machine?


I want to be able to write a instagram bot to auto comment on pictures. I already figured the normal bot part out but i don t know how to use the tor webdriver so i will be able to change my ip address regulary so instagram won t be able to block me.

from tbselenium.tbdriver import TorBrowserDriver
with TorBrowserDriver(r"\\C:\\Users\\simon\\Desktop\\Tor Browser\\Browser\\TorBrowser") as driver:
    driver.get("https://www.google.com")

I tried that but it said:

tbselenium.exceptions.TBDriverPathError: TBB path is not a directory \\C:\\Users\\simon\\Desktop\\Tor Browser\\Browser\\TorBrowser\\

Any answer is apreciated!! :)

Edit:

from tbselenium.tbdriver import TorBrowserDriver 
with TorBrowserDriver(r"\\C:\\Users\\simon\\Desktop\\Tor Browser\\Browser\\TorBrowser") as driver: 
driver.get("google.com") 

tbselenium.exceptions.TBDriverPathError: TBB path is not a directory \\C:\\Users\\simon\\Desktop\\Tor Browser\\Browser\\TorBrowser\\

Solution

  • This isn't possible with the standard selenium package.

    You can try using this github repository, which can be installed with pip install tbselenium

    Note that I haven't tried this myself.