Python 3请求错误

我正在研究Python Crash Course 2nd Ed。在文本中是一些用于访问API的代码。我的代码是从文本复制而来的,如下所示:

import requests
import json
from operator import itemgetter


#Fetch top stories and store in variable r
url = 'https://hacker-news.firebaseio.com/v0/topstories.json'
r = requests.get(url)
print(f"Status code: {r.status_code}")

# #Explore data structure
# response_dict = r.json()
# readable_file = 'hn_readable.json'
# with open(readable_file, 'w') as f:
#   json.dump(response_dict, f, indent=4)

submission_ids = r.json()
submission_dicts = []
for submission_id in submission_ids[:30]:
    #Make API call for each article
    url = f"https://hacker-news.firebasio.com/v0/item/{submission_id}.json"
    r = requests.get(url)
    print(f"id: {submission_id}\tstatus code: {r.status_code}")
    response_dict = r.json()

    #Store dictionary of each article
    submission_dict = {
        'title': response_dict['title'],
        'score': response_dict['score'],
        'comments': response_dict['descendants'],
        'link': response_dict['url'],
    }
    submission_dicts.append(submission_dict)


#Sort article by score
submission_dicts = sorted(submission_dicts, key=itemgetter('score'), reverse = True)

#Display information about each article, ranked by score
for submission_dict in submission_dicts:
    print(f"Article title: {submission_dict['title']}")
    print(f"Article link: {submission_dict['url']}")
    print(f"Score: {submission_dict['score']}")

但是,现在返回以下错误消息:

Status code: 200
Traceback (most recent call last):
  File "C:\Users\snack\AppData\Roaming\Python\Python37\site-packages\urllib3\connectionpool.py", line 677, in urlopen
    chunked=chunked,
  File "C:\Users\snack\AppData\Roaming\Python\Python37\site-packages\urllib3\connectionpool.py", line 381, in _make_request
    self._validate_conn(conn)
  File "C:\Users\snack\AppData\Roaming\Python\Python37\site-packages\urllib3\connectionpool.py", line 976, in _validate_conn
    conn.connect()
  File "C:\Users\snack\AppData\Roaming\Python\Python37\site-packages\urllib3\connection.py", line 370, in connect
    ssl_context=context,
  File "C:\Users\snack\AppData\Roaming\Python\Python37\site-packages\urllib3\util\ssl_.py", line 377, in ssl_wrap_socket
    return context.wrap_socket(sock, server_hostname=server_hostname)
  File "C:\Users\snack\Python\lib\ssl.py", line 423, in wrap_socket
    session=session
  File "C:\Users\snack\Python\lib\ssl.py", line 870, in _create
    self.do_handshake()
  File "C:\Users\snack\Python\lib\ssl.py", line 1139, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1076)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\snack\AppData\Roaming\Python\Python37\site-packages\requests\adapters.py", line 449, in send
    timeout=timeout
  File "C:\Users\snack\AppData\Roaming\Python\Python37\site-packages\urllib3\connectionpool.py", line 725, in urlopen
    method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
  File "C:\Users\snack\AppData\Roaming\Python\Python37\site-packages\urllib3\util\retry.py", line 439, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='hacker-news.firebasio.com', port=443): Max retries exceeded with url: /v0/item/23273247.json (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1076)')))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\snack\Python\proj_2\hn_submissions.py", line 24, in <module>
    r = requests.get(url)
  File "C:\Users\snack\AppData\Roaming\Python\Python37\site-packages\requests\api.py", line 76, in get
    return request('get', url, params=params, **kwargs)
  File "C:\Users\snack\AppData\Roaming\Python\Python37\site-packages\requests\api.py", line 61, in request
    return session.request(method=method, url=url, **kwargs)
  File "C:\Users\snack\AppData\Roaming\Python\Python37\site-packages\requests\sessions.py", line 530, in request
    resp = self.send(prep, **send_kwargs)
  File "C:\Users\snack\AppData\Roaming\Python\Python37\site-packages\requests\sessions.py", line 643, in send
    r = adapter.send(request, **kwargs)
  File "C:\Users\snack\AppData\Roaming\Python\Python37\site-packages\requests\adapters.py", line 514, in send
    raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='hacker-news.firebasio.com', port=443): Max retries exceeded with url: /v0/item/23273247.json (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1076)')))
[Finished in 3.6s]

我对此几乎没有经验,但是据我所知,某些身份验证失败了,并且不允许我的程序访问API,但是我不知道为什么。我尝试通过删除循环来限制API调用的次数,但这似乎无济于事。我也尝试将'''verify = False'''参数添加到requests.get行中,但这只会引发不同的错误。

任何建议将不胜感激。