我已经尝试使用python3 selenium和privoxy作为反向代理连接到tor服务。 问题是它似乎无法识别.onion域名,我发现了以下错误:
selenium.common.exceptions.WebDriverException: Message: Reached error page: about:neterror?e=dnsNotFound&u=https%3A//www.bbcnewsv2vjtpsuy.onion/&c=UTF-8&d=We%20can%E2%80%99t%20connect%20to%20the%20server%20at%20www.bbcnewsv2vjtpsuy.onion.
我正在使用以下代码:
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
from selenium.webdriver.common.proxy import Proxy, ProxyType
from selenium.webdriver.firefox.options import Options
from selenium.webdriver.firefox.firefox_profile import FirefoxProfile
from selenium import webdriver
browser = None
proxy_address = "127.0.0.1:8118"
proxy = Proxy({
'proxyType': ProxyType.MANUAL,
'httpProxy': proxy_address,
})
tor = '/usr/bin/firefox'
firefox_binary = FirefoxBinary(tor)
def get_browser(binary=None, proxy=None):
global browser
options = Options()
options.headless = True
if not browser:
# set tor profile
ff_profile = FirefoxProfile("/home/seltest/tor-browser_en-US/Browser/TorBrowser/Data/Browser/profile.default/")
browser = webdriver.Firefox(firefox_profile=ff_profile, executable_path="/home/seltest/geckodriver",firefox_binary=binary, proxy=proxy, options=options)
return browser
if __name__ == "__main__":
browser = get_browser(binary=firefox_binary, proxy=proxy)
browser.get("https://www.bbcnewsv2vjtpsuy.onion/")
print(browser.page_source)
目前没有回答
相关问题 更多 >
编程相关推荐