错误内容:
2018-07-25 11:17:49 [selenium.webdriver.remote.remote_connection] DEBUG: POST http://127.0.0.1:43357/session {"capabilities": {"firstMatch": [{}], "alwaysMatch": {"goog:chromeOptions": {"extensions": [], "args": ["--headless", "--disable-gpu", "--no-sandbox", "--disable-dev-shm-usage", "disable-infobars", "user-agent='Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36'"]}, "browserName": "chrome", "platformName": "any"}}, "desiredCapabilities": {"version": "", "goog:chromeOptions": {"extensions": [], "args": ["--headless", "--disable-gpu", "--no-sandbox", "--disable-dev-shm-usage", "disable-infobars", "user-agent='Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36'"]}, "browserName": "chrome", "platform": "ANY"}}
2018-07-25 11:17:49 [twisted] CRITICAL: Unhandled error in Deferred:
2018-07-25 11:17:49 [twisted] CRITICAL:
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/twisted/internet/defer.py", line 1386, in _inlineCallbacks
result = g.send(result)
File "/usr/local/lib/python3.5/dist-packages/scrapy/crawler.py", line 79, in crawl
self.spider = self._create_spider(*args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/scrapy/crawler.py", line 102, in _create_spider
return self.spidercls.from_crawler(self, *args, **kwargs)
File "/home/content-farm/content_crawl/content_crawl/spiders/toutiao.py", line 86, in from_crawler
spider = super(ToutiaoSpider, cls).from_crawler(crawler, *args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/scrapy/spiders/__init__.py", line 51, in from_crawler
spider = cls(*args, **kwargs)
File "/home/content-farm/content_crawl/content_crawl/spiders/toutiao.py", line 49, in __init__
self.browser = webdriver.Chrome(chrome_options=chrome_options)
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/chrome/webdriver.py", line 75, in __init__
desired_capabilities=desired_capabilities)
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webdriver.py", line 156, in __init__
self.start_session(capabilities, browser_profile)
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webdriver.py", line 251, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webdriver.py", line 318, in execute
response = self.command_executor.execute(driver_command, params)
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/remote_connection.py", line 472, in execute
return self._request(command_info[0], url, body=data)
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/remote_connection.py", line 496, in _request
resp = self._conn.getresponse()
File "/usr/lib/python3.5/http/client.py", line 1197, in getresponse
response.begin()
File "/usr/lib/python3.5/http/client.py", line 297, in begin
version, status, reason = self._read_status()
File "/usr/lib/python3.5/http/client.py", line 258, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "/usr/lib/python3.5/socket.py", line 575, in readinto
return self._sock.recv_into(b)
ConnectionResetError: [Errno 104] Connection reset by peer
参考:
https://github.com/SeleniumHQ/selenium/issues/5296
https://stackoverflow.com/questions/32328060/selenium-headless-browser-webdriver-errno-104-connection-reset-by-peer
怀疑是selenium>=3.8.1的版本有问题,强制安装3.8.0的版本,没发现问题了。
pip uninstall selenium
pip install selenium==3.8.0
下面是清理缓存的帖子
http://www.yourownlinux.com/2013/10/how-to-free-up-release-unused-cached-memory-in-linux.html
网友评论