wqxt_pdf icon indicating copy to clipboard operation
wqxt_pdf copied to clipboard

requests.exceptions.ConnectionError

Open river-li opened this issue 5 years ago • 1 comments

下载时使用requests出现以下错误

Traceback (most recent call last):
  File "/Users/river/Developer/cmanuf_spider/crawl_wqxt.py", line 392, in download_pdf
    img = self.get_img(bookid, i, jwtkey)
  File "/Users/river/Developer/cmanuf_spider/crawl_wqxt.py", line 360, in get_img
    'sec-fetch-site': 'same-origin',
  File "/Users/river/Developer/cmanuf_spider/venv/lib/python3.7/site-packages/requests/sessions.py", line 546, in get
    return self.request('GET', url, **kwargs)
  File "/Users/river/Developer/cmanuf_spider/venv/lib/python3.7/site-packages/requests/sessions.py", line 533, in request
    resp = self.send(prep, **send_kwargs)
  File "/Users/river/Developer/cmanuf_spider/venv/lib/python3.7/site-packages/requests/sessions.py", line 646, in send
    r = adapter.send(request, **kwargs)
  File "/Users/river/Developer/cmanuf_spider/venv/lib/python3.7/site-packages/requests/adapters.py", line 498, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

之后就一页都下载不下来了

改用httpx也会出现类似的错误,这是被Ban了吗?

但是发现在浏览器里还是可以访问看书

river-li avatar Feb 06 '20 16:02 river-li

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 387, in _make_request six.raise_from(e, None) File "", line 3, in raise_from File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 383, in _make_request httplib_response = conn.getresponse() File "/usr/lib/python3.6/http/client.py", line 1346, in getresponse response.begin() File "/usr/lib/python3.6/http/client.py", line 307, in begin version, status, reason = self._read_status() File "/usr/lib/python3.6/http/client.py", line 276, in _read_status raise RemoteDisconnected("Remote end closed connection without" http.client.RemoteDisconnected: Remote end closed connection without response

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/lib/python3.6/dist-packages/httpx/utils.py", line 364, in as_network_error yield File "/usr/local/lib/python3.6/dist-packages/httpx/dispatch/urllib3.py", line 109, in send pool_timeout=timeout.pool_timeout, File "/usr/lib/python3/dist-packages/urllib3/poolmanager.py", line 322, in urlopen response = conn.urlopen(method, u.request_uri, **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 398, in increment raise MaxRetryError(_pool, url, error or ResponseError(cause)) urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='lib-nuanxin.wqxuetang.com', port=443): Max retries exceeded with url: /page/img/3208298/72?k=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJwIjo3MiwidCI6MTU4MTA1OTcxNjU2NiwiYiI6IjMyMDgyOTgiLCJ3IjoxMDAwLCJrIjoie1widVwiOiBcIlh0SStuM3ZhNWZNPVwiLCBcImlcIjogXCJQekNNeWc2M3BzTHpicnlMeWVaSzd3PT1cIiwgXCJ0XCI6IFwielQxd1dBQWo1OHlXMTY1TTNid005QT09XCIsIFwiYlwiOiBcImhjeHFvcnFpZVpjPVwiLCBcIm5cIjogXCJIdERtTkVCUHQ0MD1cIn0iLCJpYXQiOjE1ODEwNTk3MTZ9.cxf4S9TgMW3kveZLVQhfKqAONqVHJwrppIdBeApqjYs (Caused by ProtocolError('Connection aborted.', RemoteDisconnected('Remote end closed connection without response',)))

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "crawl_wqxt.py", line 345, in download_pdf img = self.get_img(bookid, i, jwtkey) File "crawl_wqxt.py", line 315, in get_img 'sec-fetch-site': 'same-origin', File "/usr/local/lib/python3.6/dist-packages/httpx/client.py", line 717, in get timeout=timeout, File "/usr/local/lib/python3.6/dist-packages/httpx/client.py", line 573, in request request, auth=auth, allow_redirects=allow_redirects, timeout=timeout, File "/usr/local/lib/python3.6/dist-packages/httpx/client.py", line 593, in send request, auth=auth, timeout=timeout, allow_redirects=allow_redirects, File "/usr/local/lib/python3.6/dist-packages/httpx/client.py", line 623, in send_handling_redirects request, auth=auth, timeout=timeout, history=history File "/usr/local/lib/python3.6/dist-packages/httpx/client.py", line 659, in send_handling_auth response = self.send_single_request(request, timeout) File "/usr/local/lib/python3.6/dist-packages/httpx/client.py", line 681, in send_single_request response = dispatcher.send(request, timeout=timeout) File "/usr/local/lib/python3.6/dist-packages/httpx/dispatch/urllib3.py", line 109, in send pool_timeout=timeout.pool_timeout, File "/usr/lib/python3.6/contextlib.py", line 99, in exit self.gen.throw(type, value, traceback) File "/usr/local/lib/python3.6/dist-packages/httpx/utils.py", line 368, in as_network_error raise NetworkError(exc) from exc httpx.exceptions.NetworkError: HTTPSConnectionPool(host='lib-nuanxin.wqxuetang.com', port=443): Max retries exceeded with url: /page/img/3208298/72?k=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJwIjo3MiwidCI6MTU4MTA1OTcxNjU2NiwiYiI6IjMyMDgyOTgiLCJ3IjoxMDAwLCJrIjoie1widVwiOiBcIlh0SStuM3ZhNWZNPVwiLCBcImlcIjogXCJQekNNeWc2M3BzTHpicnlMeWVaSzd3PT1cIiwgXCJ0XCI6IFwielQxd1dBQWo1OHlXMTY1TTNid005QT09XCIsIFwiYlwiOiBcImhjeHFvcnFpZVpjPVwiLCBcIm5cIjogXCJIdERtTkVCUHQ0MD1cIn0iLCJpYXQiOjE1ODEwNTk3MTZ9.cxf4S9TgMW3kveZLVQhfKqAONqVHJwrppIdBeApqjYs (Caused by ProtocolError('Connection aborted.', RemoteDisconnected('Remote end closed connection without response',))) 2020-02-07 15:15:17,749 [ERROR] 3208298: 73/302 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 387, in _make_request six.raise_from(e, None) File "", line 3, in raise_from File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 383, in _make_request httplib_response = conn.getresponse() File "/usr/lib/python3.6/http/client.py", line 1346, in getresponse response.begin() File "/usr/lib/python3.6/http/client.py", line 307, in begin version, status, reason = self._read_status() File "/usr/lib/python3.6/http/client.py", line 276, in _read_status raise RemoteDisconnected("Remote end closed connection without" http.client.RemoteDisconnected: Remote end closed connection without response

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/lib/python3.6/dist-packages/httpx/utils.py", line 364, in as_network_error yield File "/usr/local/lib/python3.6/dist-packages/httpx/dispatch/urllib3.py", line 109, in send pool_timeout=timeout.pool_timeout, File "/usr/lib/python3/dist-packages/urllib3/poolmanager.py", line 322, in urlopen response = conn.urlopen(method, u.request_uri, **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 398, in increment raise MaxRetryError(_pool, url, error or ResponseError(cause)) urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='lib-nuanxin.wqxuetang.com', port=443): Max retries exceeded with url: /page/img/3208298/73?k=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJwIjo3MywidCI6MTU4MTA1OTcxNzYyMiwiYiI6IjMyMDgyOTgiLCJ3IjoxMDAwLCJrIjoie1widVwiOiBcIlh0SStuM3ZhNWZNPVwiLCBcImlcIjogXCJQekNNeWc2M3BzTHpicnlMeWVaSzd3PT1cIiwgXCJ0XCI6IFwielQxd1dBQWo1OHlXMTY1TTNid005QT09XCIsIFwiYlwiOiBcImhjeHFvcnFpZVpjPVwiLCBcIm5cIjogXCJIdERtTkVCUHQ0MD1cIn0iLCJpYXQiOjE1ODEwNTk3MTd9.JNIz976CILM4rJ7kW9aWo5lpzi3-m6m0fGbhL58PlWE (Caused by ProtocolError('Connection aborted.', RemoteDisconnected('Remote end closed connection without response',)))

我的这个提示

lp123sun avatar Feb 07 '20 07:02 lp123sun