Issue
For the last few days, I have been playing around with python, learned from youtube, and decided to create few things I would love to automate.
I have found the small problem - when I use my python script with Firefox browser, I can just open the Tor browser in the background and using this code:
profile = webdriver.FirefoxProfile()
profile.set_preference("network.proxy.type", 1)
profile.set_preference("network.proxy.socks", '127.0.0.1')
profile.set_preference("network.proxy.socks_port", 9150)
profile.set_preference("network.proxy.socks_remote_dns", False)
profile.update_preferences()
browser = webdriver.Firefox(firefox_profile=profile)
Everything works, it opens web browser with new ip every time. Now I tried the same with Chrome, using this code
PROXY = "127.0.0.1:9150" # IP:PORT or HOST:PORT
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--proxy-server=%s' % PROXY)
chrome = webdriver.Chrome(chrome_options=chrome_options)
I have tested this code with regular proxies (not from tor), and they did work indeed.
This is what happens to chrome when I do this: http://prntscr.com/kf8vzt
I was thinking, why did it work for Firefox, not for chrome, checked out that it might be because Tor is written based from firefox? (I might be wrong, if I am, please correct this).
Is it possible to use it with Chrome as well?
In chrome settings just tried to setup inside
Solution
To use Tor's SOCKS proxy server with chrome, include the socks protocol in the scheme with the --proxy-server
option:
PROXY = "socks5://127.0.0.1:9150"
Chrome is defaulting to an HTTP proxy which is why it can't connect to sites when you launch.
Answered By - drew010
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.