import requests
import json
def get_movies_from_tastedive(movie):
d = {"q":movie,"type":"movie","limit":"5"}
movies = requests.get("https://tastedive.com/api/similar",params=d)
x = movies.json()
print(x)
我正在运行上面的代码,试图访问TasteDive API,但不断出现以下错误:
{'error': 'Response not interpretable as json. Try printing the .text attribute'}
为什么会这样
你的问题看起来和我在Data Collection and Processing with Python期末作业中遇到的问题非常相似
我在Runestone的任务中使用了
requests_with_caching
而不是requests
修复了它端点不返回JSON。 这可能意味着您输入的文件名有问题(可能是奇怪/不可接受的字符?)
请尝试此代码以查看它返回的内容,在我的示例中,它始终返回JSON数据:
输出
相关问题 更多 >
编程相关推荐