老师你好, 下面代码是PhantomJS的收费代理设置示例
请问如果用Chrome如何设置收费代理,谢谢~
dcap = dict(webdriver.DesiredCapabilities.PHANTOMJS)
daili_url = 'proxy.xx.com'
daili_port = '8123'
authHeader = 'MYH-AUTH-MD5 sign=dsf5412x&app_key=123kjsdfxxlk3'
dcap["phantomjs.page.settings.userAgent"] = ('Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36')
dcap["phantomjs.page.customHeaders.Proxy-Authorization"] = authHeader
args = ['--load-images=false', '--disk-cache=true', '--proxy=http://{}:{}'.format(daili_url, daili_port)]
browser = webdriver.PhantomJS(service_args=args, desired_capabilities=dcap)
browser.get("http://www.0bad.com")
print (browser.page_source)
browser.quit()
带你彻底掌握Scrapy,用Django+Elasticsearch搭建搜索引擎
了解课程