如何发送多个HTTP请求python

怪异的

我正在使用pythonrequest.post()将数据发送到远程数据库。如何使用python使用不同的数据在同一URL上发送多个请求(大约20-30)?

此外,在这种情况下顺序工作是否可以正常工作,还是需要并行发出请求?

帕德拉克·坎宁安(Padraic Cunningham)

你应该看看grequests其使用要求和GEVENT

import grequests

urls = [
    'http://www.heroku.com',
    'http://python-tablib.org',
    'http://httpbin.org',
    'http://python-requests.org',
    'http://kennethreitz.com'
]

rs = (grequests.get(u) for u in urls)
grequests.map(rs)
[<Response [200]>, <Response [200]>, <Response [200]>, <Response [200]>, <Response [200]>]

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章