Python 使用api和http.client解析imdb电影数据库

Python 使用api和http.client解析imdb电影数据库,python,http.client,Python,Http.client,我正在尝试从此网站检索JSON数据: www.themoviedb.org 我只能将http.client和json用作库。 我有一个有效的API密钥,我不想在这个问题中透露 url = "https://api.themoviedb.org/3/movie/550?api_key=xxxx" conn = http.client.HTTPConnection(url,port=80) ## things work well until i call request conn.request("

我正在尝试从此网站检索JSON数据: www.themoviedb.org 我只能将http.client和json用作库。 我有一个有效的API密钥,我不想在这个问题中透露

url = "https://api.themoviedb.org/3/movie/550?api_key=xxxx"
conn = http.client.HTTPConnection(url,port=80)
## things work well until i call request
conn.request("GET","/")
错误

用于socket.getaddrinfo(主机、端口、系列、类型、协议、标志)中的res
: socket.gaierror:[Errno 11001]getaddrinfo失败


调用https站点时,请改用https连接。此外,您还错误地解析了url。这是我未经测试的示例。如果失败了,告诉我

import http.client
conn = http.client.HTTPSConnection("api.themoviedb.org")
conn.request("GET", "/3/movie/550?api_key=xxxx")
r1 = conn.getresponse()
print(r1.status, r1.reason)
if r1.status == 200:
    data1 = r1.read()

调用https站点时,请改用https连接。此外,您还错误地解析了url。这是我未经测试的示例。如果失败了,告诉我

import http.client
conn = http.client.HTTPSConnection("api.themoviedb.org")
conn.request("GET", "/3/movie/550?api_key=xxxx")
r1 = conn.getresponse()
print(r1.status, r1.reason)
if r1.status == 200:
    data1 = r1.read()

不知怎的,我觉得你在这里遗漏了一些代码不知怎的,我觉得你在这里遗漏了一些代码我试过代码,看起来它对我有用。我试过代码,看起来它对我有用。