简体   繁体   English

如何解析来自 GitHub API JSON 响应的信息?

[英]How to parse information from GitHub API JSON response?

I wanted to find a way to parse this JSON received from the GitHub REST API.我想找到一种方法来解析从 GitHub REST API 收到的这个 JSON I am trying to parse every description of all the repos in the response in Python.我正在尝试解析 Python 响应中所有存储库的每个描述。

Something like the below:类似于以下内容:

  • Do HTTP GET to the URL对 URL 执行 HTTP GET

  • If staus code is OK - turn the data into list of dicts and extract the info from each dict如果状态代码正常 - 将数据转换为字典列表并从每个字典中提取信息

     import requests r = requests.get('https://api.github.com/users/ariv797/repos') if r.status_code == 200: data = r.json() desc_lst = [e['description'] for e in data] print(desc_lst)

output输出

['Python script for bookmyshow', 'Fidellity is a voice assistant app built using fluttter', 'Flutter package for Open Weather API integration', 'Hogwarts (Harry Potter) open sandbox game made in Unity', 'Datasets of SpaceX rockets, launches, satellites, cores, ships and more.', 'Simple extension to remove audio ads on Spotify web player', 'Just scrapes the latest version of popular programming languages']

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM