简体   繁体   English

Selenium Phantomjs,代理身份验证不起作用

[英]Selenium Phantomjs, Proxy authentication is not working

I find this code on StackOverflow. 我在StackOverflow上找到了这段代码。 Tried but not working. 尝试过但不起作用。

from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
import base64
service_args = [
    '--proxy=zproxy.lum-superproxy.io:22225',
    '--proxy-type=http',
]

authentication_token = "Basic " + str(base64.b64encode(b'username:password'))

capa = DesiredCapabilities.PHANTOMJS
capa['phantomjs.page.customHeaders.Proxy-Authorization'] = authentication_token
driver = webdriver.PhantomJS(desired_capabilities=capa, service_args=service_args)

driver.get('https://www.ipify.org/')
driver.page_source

driver.close()

Note: username and password are just dummy string. 注意:用户名和密码只是虚拟字符串。

Output is: 输出为:

'<html><head></head><body></body></html>'

Can anyone help me with this issue? 谁能帮我解决这个问题?

Advance Thanks! 提前谢谢!

由于phantomjs暂停了开发,因此请尝试使用其他网络驱动程序(例如geckowebdriver或Chromedriver): https : //github.com/ariya/phantomjs/issues/15344

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM