Created
December 17, 2012 04:46
-
-
Save HQMIS/4315795 to your computer and use it in GitHub Desktop.
【Python】【Library】【requests】
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Python有大量的Standard Library(http://docs.python.org/2/library/),同时也有大量的第三方Library | |
(http://pypi.python.org/pypi),如此众多的Library,总有一些会给你带来意想不到的惊喜,这里向大家介绍一下, | |
requests模块(http://pypi.python.org/pypi/requests/0.14.2),可以更方便的进行网络协议相关的处理,大家可 | |
以将该模块看成是,对Python Standard Library urllib2的进一步封装。 | |
官方网址:http://docs.python-requests.org/en/latest/ | |
API列表:http://docs.python-requests.org/ | |
一些人的讨论:https://gist.github.com/973705 | |
Windows安装: | |
1、获取源代码 | |
2、命令行,切换到路径下,执行“python setup.py install” | |
requests模块被安装到路径“E:\Python27\Lib\site-packages\requests” | |
Requests使用: | |
可以直接import requests进行使用 | |
Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win32 | |
Type "copyright", "credits" or "license()" for more information. | |
>>> import requests | |
>>> r = requests.get('https://github.com/timeline.json') | |
>>> r.json | |
[{u'actor_attributes': {u'name': u'c4605', u'blog': u'plafer.info', | |
向URL请求数据就是这么方便; | |
对于返回的json格式的数据,就可以直接import json,使用Python Standard Library json进行数据处理; | |
当然,GET请求也可以传参,见官方网址首页的示例。 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://developer.github.com/v3/users/#get-the-authenticated-user, GitHub使用GET方式传值