Hello,
I would like to automize login and extract information using Tor browser, but the problem is that I can't find a way to open the browser to automize.
I have tried using tbselenium, but it doesn't seem to work for me. It does open the browser but shows "the proxy server is refusing connections". Have tried to find any solution, but with no luck. Tried using other than tbselenium, but nothing has worked for me.
Has anyone used tor lately to automize with it?
from selenium.webdriver import Firefox, FirefoxProfile
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
binary_path = "/Applications/TorBrowser.app/Contents/firefox" #(or something)
pref = FirefoxProfile()
pref.set_preference("network.proxy.socks", "127.0.0.1")
pref.set_preference("network.proxy.socks_port", 9050)
binary = FirefoxBinary(binary_path)
driver = Firefox(firefox_binary=binary, firefox_profile=pref)
Do not do that. Setup selenium to use the tor proxy and regular browser. Do not try and automate Tor Browser.
(Dec 19, 2018 12:21 PM)FW1738 Wrote: from selenium.webdriver import Firefox, FirefoxProfile
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
binary_path = "/Applications/TorBrowser.app/Contents/firefox" #(or something)
pref = FirefoxProfile()
pref.set_preference("network.proxy.socks", "127.0.0.1")
pref.set_preference("network.proxy.socks_port", 9050)
binary = FirefoxBinary(binary_path)
driver = Firefox(firefox_binary=binary, firefox_profile=pref)
thanks, will try that
(Dec 19, 2018 12:22 PM)Vanilla Wrote: Do not do that. Setup selenium to use the tor proxy and regular browser. Do not try and automate Tor Browser.
Could you please explain why not? It just seemed more simple.
(Dec 19, 2018 01:41 PM)theAlux Wrote: thanks, will try that
Could you please explain why not? It just seemed more simple.
For a number of reasons. Tor Browser likes to secure everything and that may not be what you want with Selenium. Best bet is just creating a Tor SOCKS then connecting that to regular browser but try Tor Browser and see what happens.
(Dec 19, 2018 01:43 PM)Vanilla Wrote: For a number of reasons. Tor Browser likes to secure everything and that may not be what you want with Selenium. Best bet is just creating a Tor SOCKS then connecting that to regular browser but try Tor Browser and see what happens.
thanks for the response. gonna see how it works with the socks.
Take a look to the tbselenium module (not tried yet) but I heard tor is working to let automation possible.
Also setting firefox to use the SOCKS at 9050 you actually need tor launched before and open,
(Dec 21, 2018 08:14 AM)FriendZone Wrote: Take a look to the tbselenium module (not tried yet) but I heard tor is working to let automation possible.
Also setting firefox to use the SOCKS at 9050 you actually need tor launched before and open,
I tried using tbselenium but after tor v8.0 it has started to not work properly (at least read that online. Shows that the proxy server is unavailable).
I made it work using the SOCKS, takes a bit more time to automate(as I need to open 2 browsers now), but will do fine for me for now till I finish the whole code.
Dec 21, 2018 03:25 PM
(This post was last modified: Dec 21, 2018 03:29 PM by FriendZone.)
(Dec 21, 2018 02:43 PM)theAlux Wrote: I tried using tbselenium but after tor v8.0 it has started to not work properly (at least read that online. Shows that the proxy server is unavailable).
I made it work using the SOCKS, takes a bit more time to automate(as I need to open 2 browsers now), but will do fine for me for now till I finish the whole code.
You can use the headless option in the webdriver arguments
(Dec 21, 2018 03:25 PM)FriendZone Wrote: You can use the headless option in the webdriver arguments
looks interesting, thanks for the tip
|