The Movie Database 支持

Hi , I am using python code to retrieve the json information from themoviedb.org. But not getting the json data in response. I am receiving response code ( 200 : success) but i am not able to get the json data

import requests import json

headers = {'Accept': 'application/json'}
payload = {'api_key': 'Giving a proper key'}

response = requests.get("http://api.themoviedb.org/3/configuration", params=payload, headers=headers) print (response) print (response.json())

Output:


JSONDecodeError Traceback (most recent call last) in () 9 print (response) 10 print (response.url) ---> 11 print (response.json()) 12 13 #response = json.loads(response.text)

C:\Users\upadhsh\AppData\Local\Continuum\Anaconda3\lib\site-packages\requests\models.py in json(self, **kwargs) 810 # used. 811 pass --> 812 return complexjson.loads(self.text, **kwargs) 813 814 @property

C:\Users\upadhsh\AppData\Local\Continuum\Anaconda3\lib\json_init_.py in loads(s, encoding, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw) 317 parse_int is None and parse_float is None and 318 parse_constant is None and object_pairs_hook is None and not kw): --> 319 return _default_decoder.decode(s) 320 if cls is None: 321 cls = JSONDecoder

C:\Users\upadhsh\AppData\Local\Continuum\Anaconda3\lib\json\decoder.py in decode(self, s, _w) 337 338 """ --> 339 obj, end = self.raw_decode(s, idx=_w(s, 0).end()) 340 end = _w(s, end).end() 341 if end != len(s):

C:\Users\upadhsh\AppData\Local\Continuum\Anaconda3\lib\json\decoder.py in raw_decode(self, s, idx) 355 obj, end = self.scan_once(s, idx) 356 except StopIteration as err: --> 357 raise JSONDecodeError("Expecting value", s, err.value) from None 358 return obj, end

JSONDecodeError: Expecting value: line 1 column 1 (char 0)

1 回复(第 1 页,共 1 页)

Jump to last post

Hi shobhit,

I'm not sure, I have tested this with many JSON parsers and never had a problem. I'm not familiar with the lib you're using, I would double check the documentation and make sure everything is being used properly.

Here's a simple example in Ruby that is working.

require 'rest_client'
api_key = "###"
request = RestClient.get 'http://api.themoviedb.org/3/configuration', { :accept => 'application/json', :params => { :api_key => api_key } }
JSON.parse(request)

2.1.5 :009 > require 'rest_client'
=> true
2.1.5 :010 > api_key = "###"
=> "###"
2.1.5 :011 > request = RestClient.get 'http://api.themoviedb.org/3/configuration', { :accept => 'application/json', :params => { :api_key => api_key } }
=> "{\"images\":{\"base_url\":\"http://image.tmdb.org/t/p/\",\"secure_base_url\":\"https://image.tmdb.org/t/p/\",\"backdrop_sizes\":[\"w300\",\"w780\",\"w1280\",\"original\"],\"logo_sizes\":[\"w45\",\"w92\",\"w154\",\"w185\",\"w300\",\"w500\",\"original\"],\"poster_sizes\":[\"w92\",\"w154\",\"w185\",\"w342\",\"w500\",\"w780\",\"original\"],\"profile_sizes\":[\"w45\",\"w185\",\"h632\",\"original\"],\"still_sizes\":[\"w92\",\"w185\",\"w300\",\"original\"]},\"change_keys\":[\"adult\",\"air_date\",\"also_known_as\",\"alternative_titles\",\"biography\",\"birthday\",\"budget\",\"cast\",\"certifications\",\"character_names\",\"created_by\",\"crew\",\"deathday\",\"episode\",\"episode_number\",\"episode_run_time\",\"freebase_id\",\"freebase_mid\",\"general\",\"genres\",\"guest_stars\",\"homepage\",\"images\",\"imdb_id\",\"languages\",\"name\",\"network\",\"origin_country\",\"original_name\",\"original_title\",\"overview\",\"parts\",\"place_of_birth\",\"plot_keywords\",\"production_code\",\"production_companies\",\"production_countries\",\"releases\",\"revenue\",\"runtime\",\"season\",\"season_number\",\"season_regular\",\"spoken_languages\",\"status\",\"tagline\",\"title\",\"translations\",\"tvdb_id\",\"tvrage_id\",\"type\",\"video\",\"videos\"]}"
2.1.5 :012 > JSON.parse(request)
=> {"images"=>{"base_url"=>"http://image.tmdb.org/t/p/", "secure_base_url"=>"https://image.tmdb.org/t/p/", "backdrop_sizes"=>["w300", "w780", "w1280", "original"], "logo_sizes"=>["w45", "w92", "w154", "w185", "w300", "w500", "original"], "poster_sizes"=>["w92", "w154", "w185", "w342", "w500", "w780", "original"], "profile_sizes"=>["w45", "w185", "h632", "original"], "still_sizes"=>["w92", "w185", "w300", "original"]}, "change_keys"=>["adult", "air_date", "also_known_as", "alternative_titles", "biography", "birthday", "budget", "cast", "certifications", "character_names", "created_by", "crew", "deathday", "episode", "episode_number", "episode_run_time", "freebase_id", "freebase_mid", "general", "genres", "guest_stars", "homepage", "images", "imdb_id", "languages", "name", "network", "origin_country", "original_name", "original_title", "overview", "parts", "place_of_birth", "plot_keywords", "production_code", "production_companies", "production_countries", "releases", "revenue", "runtime", "season", "season_number", "season_regular", "spoken_languages", "status", "tagline", "title", "translations", "tvdb_id", "tvrage_id", "type", "video", "videos"]}

找不到电影或节目?登录并创建它吧。

全站通用

s 聚焦到搜索栏
p 打开个人资料菜单
esc 关闭打开的窗口
? 打开键盘快捷键窗口

在媒体页面

b 返回(或返回上级)
e 进入编辑页面

在电视季页面

(右箭头)下一季
(左箭头)前一季

在电视集页面

(右箭头)下一集
(左箭头)上一集

在所有图像页面

a 打开添加图片窗口

在所有编辑页面

t 打开翻译选择器
ctrl+ s 提交

在讨论页面

n 创建新讨论
w 切换关注状态
p 设为公开 / 私密讨论
c 关闭 / 开放讨论
a 打开活动页
r 回复讨论
l 跳转至最新回复
ctrl+ enter 发送信息
(右箭头)下一页
(左箭头)前一页

设置

想给这个条目评分或将其添加到片单中?

登录

还不是会员?

注册加入社区