您的位置:首页 > 编程语言 > Python开发

python selenium chromedriver headless+proxy模式下获取页面为空的解决方案

2018-10-27 00:13 369 查看

获取页面返回的结果全是

[code]<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body></body></html>

解决方案:

[code]from selenium.webdriver import DesiredCapabilities
from selenium.webdriver.chrome.options import Options
from selenium.webdriver import Chrome

...
options = Options()
options.add_argument("--headless")  # 无界面
options.add_argument("--disable-gpu")  # 禁用gpu
options.add_argument("--proxy-server=127.0.0.1:8080")
capabilities = DesiredCapabilities.CHROME.copy()
capabilities['acceptSslCerts'] = True
capabilities['acceptInsecureCerts'] = True
driver = Chrome(executable_path="your path",chrome_options=options,desired_capabilities=capabilities)

 

阅读更多
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐