开发者

Python: How to make multiple HTTP POST queries in one moment?

开发者 https://www.devze.com 2022-12-20 07:11 出处:网络
How to make multiple HTTP POST queries in one moment using Python? Using an external library with an example can be a goo开发者_C百科d solution.External lib? Maybe an internal one would do the trick

How to make multiple HTTP POST queries in one moment using Python?

Using an external library with an example can be a goo开发者_C百科d solution.


External lib? Maybe an internal one would do the trick...

http://docs.python.org/library/httplib.html#examples

specifically:

params = urllib.urlencode({'spam': 1, 'eggs': 2, 'bacon': 0})

If you wanted to process multiple HTTP POST queries (asynchronous) you could cycle through them in a loop, opening subprocesses using subprocess.Popen. Although a better solution would probably be asyncore. This site has an example of using asyncore for http requests (like POST).


You should consider using threading (or maybe multiprocessing, but here the GIL is not a problem) to enable concurrent execution.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号