selenium之firefox设置代LI精简的代码示例

[python] 2024-04-20 圈点442

摘要:selenium之firefox设置代LI精简的代码示例

selenium之firefox设置代LI精简的代码示例:

from selenium import webdriver
profile = webdriver.FirefoxProfile()
profile.set_preference('network.proxy.type', 1)
profile.set_preference('network.proxy.http', 'proxy_url')
profile.set_preference('network.proxy.http_port', 3128)
profile.set_preference('network.proxy.ssl', 'proxy_url')
profile.set_preference('network.proxy.ssl_port', 3128)
profile.update_preferences()
driver = webdriver.Firefox(profile)


注意:

type值类型:整数,1为手工配置,0为不使用代理直接连接

端口值类型:整数,不是字符串

设置完成后必须update_preferences()


selenium  

感谢反馈,已提交成功,审核后即会显示