代理不起作用的Firefox配置文件selenium webdriver python

2024-10-03 06:30:33 发布

您现在位置:Python中文网/ 问答频道 /正文

代理不随此代码更改。是否有任何更改或更好的方法

from selenium import webdriver

_drivPath = r"C:\Users\abc\Desktop\geckodriver.exe"

profile = webdriver.FirefoxProfile()
profile.set_preference("network.proxy.type", 1)
profile.set_preference("network.proxy.http", "96.42.212.235")
profile.set_preference("network.proxy.http_port", 8080)
profile.update_preferences()

_driver = webdriver.Firefox(executable_path=_drivPath, 
firefox_profile=profile)
_driver.get("https://whatismyipaddress.com")

Tags: 方法代码fromimporthttp代理driverselenium