注册
登录
七宫
发表于 2021/9/29 12:20:02
12楼

只是考虑性能的时候才用

也简单

和requests差不多的

程序猿
发表于 2021/9/29 12:22:50
13楼

可是我的错误能不能解决下

他一直被拒绝链接

七宫
发表于 2021/9/29 12:25:35
14楼

完整报错

程序猿
发表于 2021/9/29 12:27:08
15楼

Traceback (most recent call last):
File /usr/lib/python3/dist-packages/urllib3/connection.py , line 141, in _new_conn
(self.host, self.port), self.timeout, **extra_kw)
File /usr/lib/python3/dist-packages/urllib3/util/connection.py , line 83, in create_connection
raise err
File /usr/lib/python3/dist-packages/urllib3/util/connection.py , line 73, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File /usr/lib/python3/dist-packages/urllib3/connectionpool.py , line 601, in urlopen
chunked=chunked)
File /usr/lib/python3/dist-packages/urllib3/connectionpool.py , line 357, in _make_request
conn.request(method, url, **httplib_request_kw)
File /usr/lib/python3.6/http/client.py , line 1254, in request
self._send_request(method, url, body, headers, encode_chunked)
File /usr/lib/python3.6/http/client.py , line 1300, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File /usr/lib/python3.6/http/client.py , line 1249, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File /usr/lib/python3.6/http/client.py , line 1036, in _send_output
self.send(msg)
File /usr/lib/python3.6/http/client.py , line 974, in send
self.connect()
File /usr/lib/python3/dist-packages/urllib3/connection.py , line 166, in connect
conn = self._new_conn()
File /usr/lib/python3/dist-packages/urllib3/connection.py , line 150, in _new_conn
self, Failed to establish a new connection: %s % e)
urllib3.exceptions.NewConnectionError: urllib3.connection.HTTPConnection object at 0x7f25b8f8a9b0 : Failed to establish a new connection: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File /home/tarena/PycharmProjects/untitled/month06/day07/10_jdspider2.py , line 76, in module
jdspider.run()
File /home/tarena/PycharmProjects/untitled/month06/day07/10_jdspider2.py , line 62, in run
self.browser.find_element_by_xpath( //div//a[@class= pn-next ] ).click()
File /usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/webdriver.py , line 394, in find_element_by_xpath
return self.find_element(by=By.XPATH, value=xpath)
File /usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/webdriver.py , line 978, in find_element
value : value})[ value ]
File /usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/webdriver.py , line 319, in execute
response = self.command_executor.execute(driver_command, params)
File /usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/remote_connection.py , line 374, in execute
return self._request(command_info[0], url, body=data)
File /usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/remote_connection.py , line 397, in _request
resp = self._conn.request(method, url, body=body, headers=headers)
File /usr/lib/python3/dist-packages/urllib3/request.py , line 70, in request
**urlopen_kw)
File /usr/lib/python3/dist-packages/urllib3/request.py , line 148, in request_encode_body
return self.urlopen(method, url, **extra_kw)
File /usr/lib/python3/dist-packages/urllib3/poolmanager.py , line 321, in urlopen
response = conn.urlopen(method, u.request_uri, **kw)
File /usr/lib/python3/dist-packages/urllib3/connectionpool.py , line 668, in urlopen
**response_kw)
File /usr/lib/python3/dist-packages/urllib3/connectionpool.py , line 668, in urlopen
**response_kw)
File /usr/lib/python3/dist-packages/urllib3/connectionpool.py , line 668, in urlopen
**response_kw)
File /usr/lib/python3/dist-packages/urllib3/connectionpool.py , line 639, in urlopen
_stacktrace=sys.exc_info()[2])
File /usr/lib/python3/dist-packages/urllib3/util/retry.py , line 388, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host= 127.0.0.1 , port=54939): Max retries exceeded with url: /session/bfadb02dd3a7de281fcf0fdc1f533f6d/element (Caused by NewConnectionError( urllib3.connection.HTTPConnection object at 0x7f25b8f8a9b0 : Failed to establish a new connection: [Errno 111] Connection refused ,))

Process finished with exit code 1

七宫
最佳答案 发表于 2021/9/29 12:29:40
16楼

应该是你点击的时候

页面元素还没有加载出来



9.29.5.jpg


程序猿
发表于 2021/9/29 12:33:30
17楼

行,我让他睡10秒钟

总够了吧

七宫
发表于 2021/9/29 12:37:47
18楼

肯定的

程序猿
发表于 2021/9/29 12:39:47
19楼

非常感谢

我知道错哪了

感谢老铁


立即注册站大爷用户,免费试用全部产品
立即注册站大爷用户,免费试用全部产品