今天在学python爬虫获取imdb网站的电影评论,但是运行后报错
import requests
import re
def download_imdb_comments():
url = "https://www.imdb.com/title/tt0110912/reviews"
para = {"ratingFilter": "1"}
headers = {'Connection': 'close'}
r = requests.get(url, params=para, headers=headers, stream=True, verify=False)
html = r.text
pattern_comment = r'<div class="text show-more__control">(.*)</div>'
comments = re.findall(pattern=pattern_comment, string=html)
return comments
requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionResetError(10054, '远程主机强迫关闭了一个现有的连接。', None, 10054, None))
我尝试用手机热点,关闭电脑防火墙,浏览器可以打开imdb网站查看,但是jyputer和pycharm还是报上面的错