[python rookie] the crawler climbed halfway and jumped out of the wrong position.

The

code is as follows:

-sharp -*- coding:utf-8 -*-
from bs4 import BeautifulSoup
import requests

def save_pic(pic, save_path):
    pic_html = requests.get(pic)
    with open(save_path, "wb") as pic_file:
        pic_file.write(pic_html.content)


url = "https://www.xkcd.com/"

for i in range(1982):
    number = i+1
    new_url = url + str(number)

    print(new_url)
    get_url = requests.get(new_url)
    try:
        get_url.raise_for_status()
    except:
        print("---error---")

    bsObj = BeautifulSoup(get_url.text,"html.parser")
    comic = bsObj.find(id = "comic")
    try:
        pic = comic.img["src"]
        pic = "https:" + pic
        save_path = "/Users/apple/Desktop////jpg/Xkcd/" + str(number) +".jpg"
        save_pic(pic,save_path)
    except:
        print("---error2---")
    

the error is as follows:

Traceback (most recent call last):
  File "/Users/apple/anaconda3/lib/python3.6/site-packages/urllib3/contrib/pyopenssl.py", line 441, in wrap_socket
    cnx.do_handshake()
  File "/Users/apple/anaconda3/lib/python3.6/site-packages/OpenSSL/SSL.py", line 1806, in do_handshake
    self._raise_ssl_error(self._ssl, result)
  File "/Users/apple/anaconda3/lib/python3.6/site-packages/OpenSSL/SSL.py", line 1538, in _raise_ssl_error
    raise SysCallError(errno, errorcode.get(errno))
OpenSSL.SSL.SysCallError: (54, "ECONNRESET")

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/apple/anaconda3/lib/python3.6/site-packages/urllib3/connectionpool.py", line 601, in urlopen
    chunked=chunked)
  File "/Users/apple/anaconda3/lib/python3.6/site-packages/urllib3/connectionpool.py", line 346, in _make_request
    self._validate_conn(conn)
  File "/Users/apple/anaconda3/lib/python3.6/site-packages/urllib3/connectionpool.py", line 850, in _validate_conn
    conn.connect()
  File "/Users/apple/anaconda3/lib/python3.6/site-packages/urllib3/connection.py", line 326, in connect
    ssl_context=context)
  File "/Users/apple/anaconda3/lib/python3.6/site-packages/urllib3/util/ssl_.py", line 329, in ssl_wrap_socket
    return context.wrap_socket(sock, server_hostname=server_hostname)
  File "/Users/apple/anaconda3/lib/python3.6/site-packages/urllib3/contrib/pyopenssl.py", line 448, in wrap_socket
    raise ssl.SSLError("bad handshake: %r" % e)
ssl.SSLError: ("bad handshake: SysCallError(54, "ECONNRESET")",)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/apple/anaconda3/lib/python3.6/site-packages/requests/adapters.py", line 440, in send
    timeout=timeout
  File "/Users/apple/anaconda3/lib/python3.6/site-packages/urllib3/connectionpool.py", line 639, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/Users/apple/anaconda3/lib/python3.6/site-packages/urllib3/util/retry.py", line 388, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host="www.xkcd.com", port=443): Max retries exceeded with url: /825 (Caused by SSLError(SSLError("bad handshake: SysCallError(54, "ECONNRESET")",),))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/apple/Desktop////downloadXkcd.py", line 18, in <module>
    get_url = requests.get(new_url)
  File "/Users/apple/anaconda3/lib/python3.6/site-packages/requests/api.py", line 72, in get
    return request("get", url, params=params, **kwargs)
  File "/Users/apple/anaconda3/lib/python3.6/site-packages/requests/api.py", line 58, in request
    return session.request(method=method, url=url, **kwargs)
  File "/Users/apple/anaconda3/lib/python3.6/site-packages/requests/sessions.py", line 508, in request
    resp = self.send(prep, **send_kwargs)
  File "/Users/apple/anaconda3/lib/python3.6/site-packages/requests/sessions.py", line 618, in send
    r = adapter.send(request, **kwargs)
  File "/Users/apple/anaconda3/lib/python3.6/site-packages/requests/adapters.py", line 506, in send
    raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host="www.xkcd.com", port=443): Max retries exceeded with url: /825 (Caused by SSLError(SSLError("bad handshake: SysCallError(54, "ECONNRESET")",),))
appledeMacBook-Pro:~ apple$

encountered a lot of inexplicable mistakes while climbing to more than 800 pages.
as a rookie, I look confused. What the heck is this?

Mar.06,2021

also encountered the same problem. I wonder if the landlord finally solved it?
this problem is also seen in Github's requests issue, but is identified as a server problem by a member of psf.


same mistake. I'm going to add a length of time to try

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e45309-44b08.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e45309-44b08.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?