赞
踩
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_h
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。