封装库
grequests
简介
requests作者写的基于gevent的异步请求库。
地址
https://github.com/kennethreitz/grequests
示例
import grequests
urls = [
'http://www.heroku.com',
'http://python-tablib.org',
'http://httpbin.org',
'http://python-requests.org',
'http://fakedomain/',
'http://kennethreitz.com'
]
rs = (grequests.get(u) for u in urls)
grequests.map(rs)
get方法参数与requests.get()参数相同,当然也支持post,put,delete等方法。
请求失败默认返回None,可以给map方法传递。exception_handler参数指定请求失败的回调函数。
map支持的参数如下:
:param requests: a collection of Request objects.
:param stream: If True, the content will not be downloaded immediately.
:param size: Specifies the number of requests to make at a time. If None, no throttling occurs.
:param exception_handler: Callback functi
4132



被折叠的 条评论
为什么被折叠?



