SSL 错误:HTTPS 连接池

cby*_*oda 5 html python web

我正在尝试通过以下代码从 IMDB 中抓取一些电影评论:

import requests
from time import sleep
url='https://www.imdb.com/title/tt0068646/reviews?ref_=tt_urv'
response= requests.get(url)
Run Code Online (Sandbox Code Playgroud)

并收到此错误:

SSLError: HTTPSConnectionPool(host='www.imdb.com', port=443): Max retries exceeded with url: /title/tt0068646/reviews?ref_=tt_urv (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')])")))
Run Code Online (Sandbox Code Playgroud)

有什么想法吗?

Mii*_*ind 3

您收到此错误是因为认证验证失败(考虑到您正在打开 IMDB,这很奇怪)。您可以通过将参数设置为 false 来关闭认证验证verify

r = requests.get(url, verify=False)
Run Code Online (Sandbox Code Playgroud)

至于证书验证失败的原因,我猜是因为您机器上的日期和时间设置不正确。