我试图从这个JSON页面('https://oa.ceair.com/common_source/airport/en_AU.json?v=1561031507803&_=1561031507712')收集一些信息,并将其转换为本地硬盘上的文本文件。 更具体地说,我只需要“match”、“label”和“value”上的字符串
import os, re, requests
def getCity():
url='https://oa.ceair.com/common_source/airport/en_AU.json?
v=1561031507803&_=1561031507712'
response=requests.get(url,verify=True)
city=re.findall('([A-Z]+)',response.text)
city=str(city)
write(city)
使用上面的代码,信息已经成功地输入到另一个文本文件中,但是,它包含了所有的原始数据
因为它是json,所以很容易使用。请求具有对它的内置支持。Response的
json
方法返回一个dict
,我们可以很容易地使用它:airport_info.txt如下所示,适用于1258行:
等等
相关问题 更多 >
编程相关推荐