官术网_书友最值得收藏!

Acquisition

Since one of the more common ways to access data is through a RESTful API, one library that you'll want to be aware of is the Python Requests library, http://www.python-requests.org/en/latest/. Dubbed HTTP for humans, it makes interacting with APIs a clean and simple experience.

Let's take a look at a sample interaction, using requests to pull down data from GitHub's API. Here, we will make a call to the API and request a list of starred repositories for a user:

import requests r = requests.get(r"https://api.github.com/users/acombs/starred") r.json() 

This will return a JSON of all the repositories the user has starred, along with attributes about each. Here is a snippet of the output for the preceding call:

Output snippet when we  return a JSON  of all the repositories

The requests library has an amazing number of features—far too many to cover here, but I do suggest you check out the documentation.

主站蜘蛛池模板: 福州市| 盱眙县| 通辽市| 玉田县| 万年县| 偃师市| 鄄城县| 长汀县| 满城县| 襄汾县| 元朗区| 巴塘县| 金湖县| 米林县| 长宁区| 汝州市| 岗巴县| 东光县| 施甸县| 青铜峡市| 布拖县| 正蓝旗| 明溪县| 成都市| 山丹县| 白城市| 抚州市| 兴宁市| 托克逊县| 漠河县| 收藏| 霍林郭勒市| 瑞安市| 偃师市| 阜阳市| 巴里| 府谷县| 沾益县| 潍坊市| 仙游县| 彩票|