【发布时间】:2017-11-24 09:17:33
【问题描述】:
我正在尝试使用 PhantomJS 和 Python 对代理服务器进行身份验证。 这就是我所拥有的
service_args = [
'--proxy=http://us-ny.proxymesh.com:31280',
'--proxy-type=http',
]
authentication_token = "Basic " + base64.b64encode(b'username:pass')
capa = DesiredCapabilities.PHANTOMJS
capa['phantomjs.page.customHeaders.Proxy-Authorization'] = authentication_token
driver = webdriver.PhantomJS( desired_capabilities=capa, service_args=service_args)
driver.get(request.url)
body = driver.page_source
print body
这只会打印出来
<html><head></head><body></body></html>
澄清一下,当我将我的 IP 添加到代理服务器 - 经过身份验证的 IP 和主机名时,这有效,但我需要它在没有它的情况下工作
【问题讨论】:
-
兄弟,我尝试在 Ubuntu 和 RedHat Linux 上使用 Python Selenium 和 PhantomJS 配置代理......花了 3 天,但代理不起作用......
-
天哪,我真的希望有办法
标签: python selenium authentication scrapy phantomjs