Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.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 2.7 PhantomJS中经过身份验证的代理-Python Selenium_Python 2.7_Selenium_Proxy_Selenium Webdriver_Phantomjs - Fatal编程技术网

Python 2.7 PhantomJS中经过身份验证的代理-Python Selenium

Python 2.7 PhantomJS中经过身份验证的代理-Python Selenium,python-2.7,selenium,proxy,selenium-webdriver,phantomjs,Python 2.7,Selenium,Proxy,Selenium Webdriver,Phantomjs,我正在尝试将经过身份验证的代理与PhantomJS-Selenium一起使用 下面是我的Chromedriver代码,它运行良好。 然而, 我以前从未尝试过使用PhantomJS。 根据代理提供商提供的说明,它要求我在代码中添加以下行 page.customHeaders={'Proxy-Authorization':'Basic'+btoa('USERNAME:PASSWORD')} 有人能告诉我在哪里加这个吗 提前谢谢 from selenium import webdriver proxi

我正在尝试将经过身份验证的代理与PhantomJS-Selenium一起使用

下面是我的Chromedriver代码,它运行良好。 然而, 我以前从未尝试过使用PhantomJS。 根据代理提供商提供的说明,它要求我在代码中添加以下行

page.customHeaders={'Proxy-Authorization':'Basic'+btoa('USERNAME:PASSWORD')}

有人能告诉我在哪里加这个吗

提前谢谢

from selenium import webdriver
proxies = 'http://us.proxymesh.com:31280'
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--proxy-server=%s' % proxies)
b = webdriver.Chrome(chrome_options=chrome_options)
b.get('http://www.google.com/ncr')

你能试试这个
service_args=['--proxy={}.format(proxy),'--proxy type=socks5']
然后
driver=webdriver.PhantomJS('PhantomJS.exe',service_args=service_args)