如何修复http.client.UnknownProtocol:HTTP / 2.0错误

时间:2018-12-21 22:21:05

标签: python http urllib

我正在尝试使用urllib从python的网页中获取一些数据,但出现此错误:http.client.UnknownProtocol:HTTP / 2.0 这是代码:

from urllib.request import urlopen

# I put this to avoid CORS 
opener = build_opener()
opener.addheaders = [('User-agent', 'Mozilla/5.0')]
install_opener(opener)

base_page = 'https://stackoverflow.com/example_hypothetical_page'
page = urlopen(base_page)

奇怪的是,几天前相同的代码起作用了……唯一的变化是我重新安装了操作系统,然后又重新安装了所有内容

0 个答案:

没有答案