我在本地计算机上使用硒,但有时我会收到一个我不完全理解的套接字错误。到目前为止,重新启动(Python)应用程序对我有用。
可能导致这种情况的原因是什么?
driver = webdriver.Firefox(firefox_profile=someProfile)
driver.get(someLink)
堆栈追踪:
Traceback (most recent call last):
File "/home/foo/.conda/envs/myenv3/lib/python3.5/site-packages/IPython/core/interactiveshell.py", line 2885, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-2-cdc559ddfda1>", line 1, in <module>
driver.get(link)
File "/home/foo/.conda/envs/myenv3/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py", line 245, in get
self.execute(Command.GET, {'url': url})
File "/home/foo/.conda/envs/myenv3/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py", line 231, in execute
response = self.command_executor.execute(driver_command, params)
File "/home/foo/.conda/envs/myenv3/lib/python3.5/site-packages/selenium/webdriver/remote/remote_connection.py", line 395, in execute
return self._request(command_info[0], url, body=data)
File "/home/foo/.conda/envs/myenv3/lib/python3.5/site-packages/selenium/webdriver/remote/remote_connection.py", line 425, in _request
self._conn.request(method, parsed_url.path, body, headers)
File "/home/foo/.conda/envs/myenv3/lib/python3.5/http/client.py", line 1083, in request
self._send_request(method, url, body, headers)
File "/home/foo/.conda/envs/myenv3/lib/python3.5/http/client.py", line 1128, in _send_request
self.endheaders(body)
File "/home/foo/.conda/envs/myenv3/lib/python3.5/http/client.py", line 1079, in endheaders
self._send_output(message_body)
File "/home/foo/.conda/envs/myenv3/lib/python3.5/http/client.py", line 911, in _send_output
self.send(msg)
File "/home/foo/.conda/envs/myenv3/lib/python3.5/http/client.py", line 854, in send
self.connect()
File "/home/foo/.conda/envs/myenv3/lib/python3.5/http/client.py", line 826, in connect
(self.host,self.port), self.timeout, self.source_address)
File "/home/foo/.conda/envs/myenv3/lib/python3.5/socket.py", line 711, in create_connection
raise err
File "/home/foo/.conda/envs/myenv3/lib/python3.5/socket.py", line 702, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused
答案 0 :(得分:0)
它看起来问题与某些忽略代理设置的http库有关。你正在使用什么版本的python?尝试使用Python 2.x,看看它是怎么回事。