如何使用iTunes的API下载文件并使用python导入字符串?

How to use iTune's API to download a file and import the string using python?

iTunes 有一个 API 让我下载关于应用程序的文件。

当我输入 https://itunes.apple.com/search?term=yelp&country=us&entity=software 时,它会提示我下载一个文件。

python中是否有下载文件并将字符串导入变量的命令?

谢谢

要下载文件的内容,您只需执行以下操作:

import requests
string_var = requests.get("https://itunes.apple.com/search?term=yelp&country=us&entity=software").content

看到,响应是一个 JSON 文件,您可能想要添加:

import json
resp_dict = json.loads(string_var)

这将为您提供一本词典

这些只是小片段。我用了 Python2.7