简体   繁体   English

如何使用Selenium和Python启动Tor浏览器

[英]How to initiate Tor Browser using Selenium and Python

I m trying to open the webpage in Tor Browser using Python 我正在尝试使用Python在Tor浏览器中打开网页

Code: 码:

# Start :Code For TOR Browser
from selenium import webdriver
from selenium.webdriver.firefox.firefox_profile import FirefoxProfile
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

# path to TOR binary
binary = FirefoxBinary(r'C:\\Tor Browser\\Browser\\firefox.exe')
# binary = FirefoxBinary(r'C:\\Program Files (x86)\\Vidalia Bridge Bundle\\Tor\\tor.exe')
#path to TOR profile
profile = FirefoxProfile(r'C:\\Tor Browser\\Browser\\TorBrowser\\Data\\Browser\\profile.default')

# cap = DesiredCapabilities().FIREFOX
# cap["marionette"] = False
# driver = webdriver.Firefox(firefox_binary= binary, executable_path="C:\\Python\\scrapy-master\\Projects\\kgooglecom\\WithScreenshot\\geckodriver.exe")

driver = webdriver.Firefox(firefox_profile= profile, firefox_binary= binary, executable_path="C:\\Python\\scrapy-master\\Projects\\kgooglecom\\WithScreenshot\\geckodriver.exe")
# driver = webdriver.Firefox(firefox_profile=profile, firefox_binary= binary, executable_path=r"C:\\Python\\scrapy-master\\Projects\\kgooglecom\\WithScreenshot\\geckodriver.exe")
driver.get("https://www.google.com")
driver.save_screenshot("screenshot1.png")
driver.quit()

# End :Code For TOR Browser

I Use this link to download the geckodriver 我使用此链接下载geckodriver

Error: 错误:

在此处输入图片说明

Please suggest me how to resolve this error 请建议我如何解决此错误

To open a webpage through Tor Browser using Python you can use the Firefox Profile and the tor daemon and you can use the following solution: 要使用Python通过Tor浏览器打开网页,您可以使用Firefox配置文件tor守护程序,并且可以使用以下解决方案:

  • Code Block: 代码块:

     from selenium import webdriver from selenium.webdriver.firefox.firefox_profile import FirefoxProfile import os torexe = os.popen(r'C:\\Users\\AtechM_03\\Desktop\\Tor Browser\\Browser\\TorBrowser\\Tor\\tor.exe') profile = FirefoxProfile(r'C:\\Users\\AtechM_03\\Desktop\\Tor Browser\\Browser\\TorBrowser\\Data\\Browser\\profile.default') profile.set_preference('network.proxy.type', 1) profile.set_preference('network.proxy.socks', '127.0.0.1') profile.set_preference('network.proxy.socks_port', 9050) profile.set_preference("network.proxy.socks_remote_dns", False) profile.update_preferences() driver = webdriver.Firefox(firefox_profile= profile, executable_path=r'C:\\Utility\\BrowserDrivers\\geckodriver.exe') driver.get("http://check.torproject.org") 
  • Browser Snapshot: 浏览器快照:

Tor_Browser

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 GeckoDriver 和 Selenium 到 ZA7F5F35426B927411FC9231B56382173 启动使用默认 Firefox 到 68.9.0esr 的 Tor 浏览器 9.5 - How to initiate a Tor Browser 9.5 which uses the default Firefox to 68.9.0esr using GeckoDriver and Selenium through Python 使用 selenium package 使用 python 打开浏览器 - open tor browser with python using selenium package 如何使用 Selenium 和 python 在 Tor 浏览器中单击按钮 - How to click a button in Tor Browser with Selenium and python 如何使用 Selenium 和 Python 启动基于 Chromium 的 Vivaldi 浏览器 session - How to initiate a Chromium based Vivaldi browser session using Selenium and Python 如何在 Windows 上使用 Selenium 和 Python 启动 Brave 浏览器 - How to initiate Brave browser using Selenium and Python on Windows 如何使用勇敢的浏览器使用 python 启动 selenium web 驱动程序 - How to initiate selenium web driver with brave browser using python Python Selenium 与 TOR 浏览器的绑定 - Python Selenium binding with TOR browser 如何使用 Python 连接到 Tor 浏览器 - How to connect to Tor browser using Python 如何使用 python 在 mac 中打开 Tor 浏览器? - how to open tor browser in mac using python? 在python中使用Selenium,PhantomJS和Tor - Using Selenium, PhantomJS and Tor in python
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM