Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Selenium:使用用户名/密码通过代理连接-如何?_Python_Selenium_Selenium Webdriver_Proxy - Fatal编程技术网

Python Selenium:使用用户名/密码通过代理连接-如何?

Python Selenium:使用用户名/密码通过代理连接-如何?,python,selenium,selenium-webdriver,proxy,Python,Selenium,Selenium Webdriver,Proxy,同样的问题有很多,但所有答案都过时了,例如: 这是2016年的过时答案: 2017年的另一个过时答案是: 无论如何,当我尝试使用需要用户名+密码的代理时,如下所示: from selenium import webdriver profile = webdriver.FirefoxProfile() profile.set_preference("network.proxy.type", 1) profile.set_preference("network.proxy.http", PROXY

同样的问题有很多,但所有答案都过时了,例如:

这是2016年的过时答案: 2017年的另一个过时答案是:

无论如何,当我尝试使用需要用户名+密码的代理时,如下所示:

from selenium import webdriver
profile = webdriver.FirefoxProfile()
profile.set_preference("network.proxy.type", 1)
profile.set_preference("network.proxy.http", PROXY_HOST)
profile.set_preference("network.proxy.http_port", PROXY_PORT)
profile.set_preference("network.proxy.socks_username", USERNAME)
profile.set_preference("network.proxy.socks_password", PASSWORD)
profile.set_preference('network.proxy.ssl', PROXY_HOST)
profile.set_preference('network.proxy.ssl_port', PROXY_PORT)

profile.update_preferences()

# executable_path  = define the path if u don't already have in the PATH system variable. 

driver = webdriver.Firefox(firefox_profile=profile)
page = driver.get('http://whatismyipaddress.com/')
这根本不起作用

现在通过代理(同时提供用户名和密码)进行连接的最干净的方式是什么

(如果你能解释为什么我的代码不起作用,而事实上它不起作用对我来说毫无意义,那么你就可以获得额外的分数!)