我被错误和到期提交严重困扰。
conn = http.client.HTTPSConnection("api.themoviedb.org/3")
conn.request('GET', '/person/5064/movie_credits?api_key={api_key}&language=en-US')
r1 = conn.getresponse()
print(r1.status, r1.reason)
data1 = r1.read()
print(type(data1))
print(data1)
我尝试使用我的 api 密钥从浏览器访问 api,它可以工作。在笔记本电脑上运行代码时,出现以下错误:
C:\Users\Dhaval Desai\Desktop\Gatech\DVA\hw1-skeleton>"C:/Users/Dhaval Desai/AppData/Local/Programs/Python/Python37/python.exe" "c:/Users/Dhaval Desai/Desktop/Gatech/DVA/hw1-skeleton/Q1/submission.py"
Traceback (most recent call last):
File "c:/Users/Dhaval Desai/Desktop/Gatech/DVA/hw1-skeleton/Q1/submission.py", line 311, in <module>
tmdb_api_utils.get_movie_credits_for_person("5064")
File "c:/Users/Dhaval Desai/Desktop/Gatech/DVA/hw1-skeleton/Q1/submission.py", line 214, in get_movie_credits_for_person
conn.request("GET", "/movie/550?api_key=8dcea7325ee7c9571a21d3184cffdf34&language=en-US")
File "C:\Users\Dhaval Desai\AppData\Local\Programs\Python\Python37\lib\http\client.py", line 1252, in request
self._send_request(method, url, body, headers, encode_chunked)
File "C:\Users\Dhaval Desai\AppData\Local\Programs\Python\Python37\lib\http\client.py", line 1298, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "C:\Users\Dhaval Desai\AppData\Local\Programs\Python\Python37\lib\http\client.py", line 1247, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "C:\Users\Dhaval Desai\AppData\Local\Programs\Python\Python37\lib\http\client.py", line 1026, in _send_output
self.send(msg)
File "C:\Users\Dhaval Desai\AppData\Local\Programs\Python\Python37\lib\http\client.py", line 966, in send
self.connect()
File "C:\Users\Dhaval Desai\AppData\Local\Programs\Python\Python37\lib\http\client.py", line 1414, in connect
super().connect()
File "C:\Users\Dhaval Desai\AppData\Local\Programs\Python\Python37\lib\http\client.py", line 938, in connect
(self.host,self.port), self.timeout, self.source_address)
File "C:\Users\Dhaval Desai\AppData\Local\Programs\Python\Python37\lib\socket.py", line 707, in create_connection
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
File "C:\Users\Dhaval Desai\AppData\Local\Programs\Python\Python37\lib\socket.py", line 748, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno 11001] getaddrinfo failed