简体   繁体   English

硒(python):Errno 101连接在屏幕截图上被拒绝?

[英]selenium (python): Errno 101 Connection Refused on screenshot?

I have just today encountered a new error in a previously working piece of code. 我今天刚刚在以前的代码段中遇到了一个新错误。 Here is the code in question, using selenium webdriver in python: 这是有问题的代码,在python中使用Selenium Webdriver:

driver = webdriver.Chrome(chrome_options=options) driver.get("http://www.reference.com")) data = driver.get_screenshot_as_base64()

and the error I receive: 和我收到的错误:

File "screenshotMachine.py", line 270, in receiveJob
doCaptureTearsheet(jobBody)
    File "screenshotMachine.py", line 191, in doCaptureTearsheet
url = captureTearsheet(campaignID, h, w, m, tearsheetNumber, month, source)
    File "/home/trevor/storage/PaperG/tearsheet-service/worker/etearsheet.py", line 82, in captureTearsheet
data = driver.get_screenshot_as_base64()
    File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 725, in get_screenshot_as_base64
    return self.execute(Command.SCREENSHOT)['value']
    File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 171, in execute
response = self.command_executor.execute(driver_command, params)
    File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/remote_connection.py", line 347, in execute
return self._request(command_info[0], url, body=data)
    File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/remote_connection.py", line 377, in _request
self._conn.request(method, parsed_url.path, body, headers)
    File "/usr/lib/python2.7/httplib.py", line 973, in request
self._send_request(method, url, body, headers)
    File "/usr/lib/python2.7/httplib.py", line 1007, in _send_request
self.endheaders(body)
    File "/usr/lib/python2.7/httplib.py", line 969, in endheaders
self._send_output(message_body)
    File "/usr/lib/python2.7/httplib.py", line 829, in _send_output
self.send(msg)
    File "/usr/lib/python2.7/httplib.py", line 791, in send
self.connect()
    File "/usr/lib/python2.7/httplib.py", line 772, in connect
    self.timeout, self.source_address)
    File "/usr/lib/python2.7/socket.py", line 571, in create_connection
    raise err
    error: [Errno 111] Connection refused

Like I said, this code was working fine until this morning. 就像我说的那样,直到今天早上这段代码都可以正常工作。 A git blame shows that this code has not changed in over a month. git怪显示该代码在一个多月内没有更改。 I'm at a loss of what to do here, any suggestions? 我不知所措,有什么建议吗?

So it seems it was an error on my part. 所以看来这是我的错误。 I was calling driver.quit() before taking the screenshot. 在截屏之前,我曾打电话给driver.quit() I think this error message could have been more clear, but oh well. 我认为此错误消息本来应该更清楚,但是哦。

Going to leave the answer here just in case it helps anyone else. 为了以防万一,可以将答案留在这里。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM