将默认设置设为'无代理'在Selenium Firefox中

时间:2016-03-21 11:15:03

标签: python selenium proxy

每当我使用命令

在python中使用Selenium打开Firefox时
browser = webdriver.Firefox()

默认代理配置设置为"使用系统代理设置"。我没有在系统中配置任何代理。无论何时浏览器打开,它都会显示"代理服务器拒绝连接"。

如何打开浏览器以使默认代理设置设置为"无代理" ?

请帮忙。提前谢谢。

1 个答案:

答案 0 :(得分:1)

我将从我的记忆中发帖

import os
from selenium import webdriver

profile = webdriver.FirefoxProfile()
profile.set_preference('network.proxy.Kind','Direct')
webdriver.Firefox(profile)

要使用默认配置文件,您必须指定它

profile = webdriver.FirefoxProfile(path_to_profile_in_your_pc)
webdriver.Firefox(profile)
相关问题