我在StackOverflow上找到了这段代码。尝试过但不起作用。
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()
注意:用户名和密码只是虚拟字符串。
输出为:
'<html><head></head><body></body></html>'
有人可以帮助我解决这个问题吗?
提前谢谢!
答案 0 :(得分:0)
由于phantomjs暂停了开发,请尝试使用其他Webdriver(例如geckowebdriver或Chromedriver):https://github.com/ariya/phantomjs/issues/15344