2

我在代理服务器后面。使用Selenium 2.39,Python 2.7.6和ChromeDriver 2.9,只要我在Chrome实例上调用.quit(),就会得到HTTP 407错误。使用FirefoxDriver时不会出现此类错误。Selenium ChromeDriver - driver.quit上的HTTP 407()

Traceback (most recent call last): 
File "C:\Users\Tetrinity\Desktop\chrometest.py", line 7, in <module> 
    browser.quit() 
    File "C:\Python27\lib\site-packages\selenium-2.39.0-py2.7.egg\selenium\webdriver\chrome\webdriver.py", line 82, in quit 
    self.service.stop() 
    File "C:\Python27\lib\site-packages\selenium-2.39.0-py2.7.egg\selenium\webdriver\chrome\service.py", line 97, in stop 
    url_request.urlopen("http://127.0.0.1:%d/shutdown" % self.port) 
    File "C:\Python27\lib\urllib2.py", line 127, in urlopen 
    return _opener.open(url, data, timeout) 
    File "C:\Python27\lib\urllib2.py", line 410, in open 
    response = meth(req, response) 
    File "C:\Python27\lib\urllib2.py", line 523, in http_response 
    'http', request, response, code, msg, hdrs) 
    File "C:\Python27\lib\urllib2.py", line 448, in error 
    return self._call_chain(*args) 
    File "C:\Python27\lib\urllib2.py", line 382, in _call_chain 
    result = func(*args) 
    File "C:\Python27\lib\urllib2.py", line 531, in http_error_default 
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp) 
HTTPError: HTTP Error 407: Proxy Authentication Required (The ISA Server requires authorization to fulfill the request. Access to the Web Proxy service is denied. ) 

的问题可以归纳为以下的脚本,我已经保存为chrometest.py(如上面的堆栈跟踪看到):

from selenium import webdriver 
browser = webdriver.Chrome() 
browser.get("http://www.google.co.uk") 
browser.quit() 

这个脚本成功打开浏览器并导航到谷歌。 .quit()然后导致上面的崩溃,留下一个死的ChromeDriver实例。有什么可能导致这种情况,我该如何预防它?

研究发现了很多答案aren't quite relevant,overcomplicate thingsclaim it's an issue that was already fixed

回答

3

因为我今天浪费了几个小时试图追踪解决方案,我以为我会记录什么对我有用。我通过打开Internet选项>连接> LAN设置>高级并将127.0.0.1插入到例外框中解决了此问题。完成此操作后,chrometest.py无错地完成,并且ChromeDriver窗口已成功关闭。

此解决方案的信用应转到提问者here。奇怪的是,这个问题从来没有出现在我的搜索。当我几乎完成了这个问题的原始版本的输入时,它出现在类似问题部分(去图!)。

+0

我给出了图片格式的相同输出。感谢您的帮助。 –

1

这是Chrome浏览器的问题。以下步骤将为您提供修复。

1 |取消选中该复选框,By Proxy server for local address

enter image description here

2 |点击高级选项卡

enter image description here

3 |在例外面板下输入127.0.0.1

4 |点击确定

相关问题