Asynchronous Requests with Python requests

前端 未结 12 1451
予麋鹿
予麋鹿 2020-11-22 08:47

I tried the sample provided within the documentation of the requests library for python.

With async.map(rs), I get the response codes, but I want to get

12条回答
  •  闹比i
    闹比i (楼主)
    2020-11-22 08:55

    I know this has been closed for a while, but I thought it might be useful to promote another async solution built on the requests library.

    list_of_requests = ['http://moop.com', 'http://doop.com', ...]
    
    from simple_requests import Requests
    for response in Requests().swarm(list_of_requests):
        print response.content
    

    The docs are here: http://pythonhosted.org/simple-requests/

提交回复
热议问题