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

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.

主站蜘蛛池模板: 德安县| 阿拉善盟| 定西市| 蓬莱市| 沐川县| 华坪县| 九龙坡区| 宜城市| 莒南县| 贺州市| 胶南市| 原平市| 晋州市| 得荣县| 克山县| 兴仁县| 三穗县| 万盛区| 香港| 博客| 抚宁县| 沾益县| 普陀区| 宁强县| 莆田市| 琼结县| 阳曲县| 明光市| 舞阳县| 瑞丽市| 商都县| 马龙县| 甘泉县| 沂水县| 夏邑县| 洛扎县| 德格县| 察雅县| 永吉县| 莆田市| 舒城县|