我试图用http.client调用API,错误说'http.client‘没有属性'HTTPSConnection’。

守则是:
import http.client
conn = http.client.HTTPSConnection("www.banxico.org.mx")
payload = ''
headers = {}
conn.request("GET", "/SieAPIRest/service/v1/series/SP68257/datos/2022-11-11/2022-11-11?token=04021aac739b77e232d9670147936836e9e9fc31e08bde26665c0f013df94471", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))代码在jupyther笔记本上工作得很好,但在网络上就不行了。
发布于 2022-11-12 07:30:14
包http.client依赖于在web浏览器中运行时不支持的模块(如ssl )。重写代码以使用支持的API(如pyfetch )。
https://stackoverflow.com/questions/74410387
复制相似问题