我怎么去一个网站使用硒



大家好。我添加了一个driver.get()到我的代码,它不工作,如果你能帮助我,这将是惊人的,谢谢你无论如何。

长话短说,它不会转到我给它的链接。

代码:

from selenium.webdriver.firefox.firefox_profile import FirefoxProfile
from selenium import webdriver
import os
torexe = os.popen(
r'C:UsersandreDesktopProgramsTor BrowserBrowserfirefox.exe')
profile = FirefoxProfile(
r'C:UsersandreDesktopProgramsTor BrowserBrowserTorBrowserDataBrowserprofile.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()
firefox_options = webdriver.FirefoxOptions()
firefox_options.binary_location = r'C:UsersandreDesktopProgramsTor BrowserBrowsergeckodriver.exe'
driver = webdriver.Firefox(firefox_profile=profile, options=firefox_options,
executable_path=r'C:UsersandreDesktopProgramsTor BrowserBrowsergeckodriver.exe')
driver.get(
"https://www.google.com/search?client=firefox-b-1-d&q=thank+youfor+your+help")

错误:

Traceback (most recent call last):
File "c:UsersandreDesktopPython dsicord bottewasf.py", line 17, in <module>
driver = webdriver.Firefox(firefox_profile=profile, options=firefox_options,
File "C:UsersandreAppDataLocalProgramsPythonPython39libsite-packagesseleniumwebdriverfirefoxwebdriver.py", line 170, in __init__
RemoteWebDriver.__init__(
File "C:UsersandreAppDataLocalProgramsPythonPython39libsite-packagesseleniumwebdriverremotewebdriver.py", line 157, in __init__ 
self.start_session(capabilities, browser_profile)
File "C:UsersandreAppDataLocalProgramsPythonPython39libsite-packagesseleniumwebdriverremotewebdriver.py", line 252, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "C:UsersandreAppDataLocalProgramsPythonPython39libsite-packagesseleniumwebdriverremotewebdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "C:UsersandreAppDataLocalProgramsPythonPython39libsite-packagesseleniumwebdriverremoteerrorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: Process unexpectedly closed with status 64```

当我在阅读如何使用Python连接到Tor浏览器时,我注意到你的代码基本上是相同的。所以我在谷歌上搜索了更多,发现:Typically Tor listens for SOCKS connections on port 9050. Tor Browser listens on port 9150.尝试将插座端口更改为9150

最新更新