python 使用selenium 的webdriver.PhantomJS出错? 10
fromseleniumimportwebdriverdriver=webdriver.PhantomJS(service_args=['--ignore-ssl-err...
from selenium import webdriver
driver = webdriver.PhantomJS(service_args=['--ignore-ssl-errors=true'])
driver.get('http://example.com')
html_content = driver.page_source
print(html_content)
driver.close()
错误信息
selenium.common.exceptions.WebDriverException: Message: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><head>
<title>Proxy error: 502 Server dropped connection.</title>
</head><body>
<h1>502 Server dropped connection</h1>
<p>The following error occurred while trying to access <strong>http://127.0.0.1:53329/wd/hub/session</strong>:<br><br>
<strong>502 Server dropped connection</strong></p>
<hr>Generated Fri, 22 Sep 2017 09:31:26 GMT by Polipo on <em>P-V-7:8123</em>.
</body></html> 展开
driver = webdriver.PhantomJS(service_args=['--ignore-ssl-errors=true'])
driver.get('http://example.com')
html_content = driver.page_source
print(html_content)
driver.close()
错误信息
selenium.common.exceptions.WebDriverException: Message: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><head>
<title>Proxy error: 502 Server dropped connection.</title>
</head><body>
<h1>502 Server dropped connection</h1>
<p>The following error occurred while trying to access <strong>http://127.0.0.1:53329/wd/hub/session</strong>:<br><br>
<strong>502 Server dropped connection</strong></p>
<hr>Generated Fri, 22 Sep 2017 09:31:26 GMT by Polipo on <em>P-V-7:8123</em>.
</body></html> 展开
2个回答
展开全部
Proxy error: 502 Server dropped connection.
是不是服务开启了代理
是不是服务开启了代理
追问
什么意思,同样环境下我用 webdriver.Chrome是可以的,换成Phantomjs就不行了
追答
加请求头试试
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询