【发布时间】:2017-11-13 13:35:50
【问题描述】:
我想提高 selenium 的性能(在 selenium-python 上工作)。所以我想切换到无头浏览器,因为 GUI 不是必需的。
我为phantomJS 设置路径变量并运行
driver = webdriver.PhantomJS()
收到error 后,我在初始化驱动程序时设置了路径和服务参数(经过几十个 stackoverflow 和 google 组
phantomjs_path = r"C:\Users\sachin.nandakumar\AppData\Local\Continuum\anaconda3\phantomjs\bin\phantomjs.exe"
service_args = [ '--proxy=10.118.132.29:80', '--proxy-type=http',]
driver = webdriver.PhantomJS(executable_path=phantomjs_path,service_args=service_args)
但我仍然遇到同样的错误。 (错误在下面详细说明)
后来我也尝试了HtmlUnitDriver。但同样的错误再次发生。
无头浏览器在代理(企业防火墙)后面工作是否存在任何问题?或者如果是关于一些身份验证问题,我没有找到解决这些问题的方法。
E
======================================================================
ERROR: test_start (__main__.TestWeb)
----------------------------------------------------------------------
Traceback (most recent call last):
File "...Crawler\crawl_core\src_main\run.py", line 26, in setUp
driver = webdriver.PhantomJS(executable_path=phantomjs_path,service_args=service_args)
File "...\anaconda3\lib\site-packages\selenium\webdriver\phantomjs\webdriver.py", line 58, in __init__
desired_capabilities=desired_capabilities)
File "...\anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 151, in __init__
self.start_session(desired_capabilities, browser_profile)
File "...\anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 240, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "...\anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 308, in execute
self.error_handler.check_response(response)
File "...\anaconda3\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 165, in check_response
raise exception_class(value)
selenium.common.exceptions.WebDriverException: Message: <HTML><HEAD>
<TITLE>Access Denied</TITLE>
</HEAD>
<BODY>
<FONT face="Helvetica">
<big><strong></strong></big><BR>
</FONT>
<blockquote>
<TABLE border=0 cellPadding=1 width="80%">
<TR><TD>
<FONT face="Helvetica">
<big>Access Denied (authentication_failed)</big>
<BR>
<BR>
</FONT>
</TD></TR>
<TR><TD>
<FONT face="Helvetica">
Your credentials could not be authenticated: "General authentication failure due to bad user ID or authentication token.". You will not be permitted access until your credentials can be verified.
</FONT>
</TD></TR>
<TR><TD>
<FONT face="Helvetica">
This is typically caused by an incorrect username and/or password, but could also be caused by network problems.
</FONT>
</TD></TR>
<TR><TD>
<FONT face="Helvetica" SIZE=2>
<BR>
For assistance, contact your network support team.
</FONT>
</TD></TR>
</TABLE>
</blockquote>
</FONT>
</BODY></HTML>
【问题讨论】:
标签: python selenium-webdriver phantomjs