我对此进行了研究,但我得到了解决方案:
from selenium import webdriver
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', 9050)
driver = webdriver.Firefox(profile)
driver.get('http://estoeslapollaconcebol.la')
它给出了这个错误:
无法加载配置文件。Profile Dir: C:\Users\HPPAV1~1\AppData\Local\Temp\tmppcuwx3xd Firefox输出:无
当我尝试那个解决方案的时候。
from selenium import webdriver
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
profile=webdriver.FirefoxProfile('C:\\Users\\HP PAV 15\\Desktop\\Tor Browser\\Browser\\TorBrowser\\Data\\Browser\\profile.default\\')
binary =FirefoxBinary('C:\\Users\\HP PAV 15\\Desktop\\Tor Browser\\Browser\\firefox')
#browser = binary.launch_browser(profile)
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)
browser=webdriver.Firefox( binary, profile)
browser.get("http://yahoo.com")
browser.save_screenshot("/Users/admin/Pictures/screenshot.png")
browser.close()
它给出了以下错误:
回溯(最近一次调用):文件“C:/Python34 34/torFirstscript.py”,第10行,在browser=webdriver.Firefox(二进制,配置文件)文件第46行,在init self.NATIVE_EVENTS_ALLOWED和self.profile.native_events_enabled中) AttributeError:'FirefoxBinary‘对象没有属性'native_events_enabled’
通过应用
browser=webdriver.Firefox( firefox_binary = binary, firefox_profile = profile)
我发现了一个错误:
追溯(最近一次调用):文件"C:\Python34\torfirstscript.py",第9行,在browser=webdriver.Firefox( firefox_binary =二进制,firefox_profile = >profile)文件第59行,在init self.binary中,超时文件"C:\Python34\lib\site-packages\selenium-2.43.0->py3.4.egg\selenium\webdriver\firefox\extension_connection.py",第47行,在>init self.binary.launch_browser(self.profile)文件第64行中,在文件"C:\Python34\lib\site-packages\selenium-2.43.0-py3.4.egg\selenium\webdriver\firefox\firefox_binary.py",第108行launch_browser self._wait_until_connectable()中,在_wait_until_connectable self.profile.path中,self._get_firefox_output()) selenium.common.exceptions.WebDriverException:消息:“无法加载配置文件。Profile Dir:>C:\Users\HPPAV1~1\AppData\Local\Temp\tmpig7zvx_0\webdriver-py-profilecopy Firefox输出:无“
以那个图像作为输出。
发布于 2021-09-08 17:49:51
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from selenium import webdriver
caps = DesiredCapabilities.FIREFOX
caps['proxy'] = {
'proxyType': 'MANUAL',
'socksProxy': '127.0.0.1:9050',
'socksVersion': 5
}
driver = webdriver.Firefox(executable_path=r"C:\webdrivers\geckodriver.exe", capabilities=caps)
在我的例子中,这段代码是唯一起作用的。
https://stackoverflow.com/questions/34316878
复制相似问题