How to limit download rate of HTTP requests in requests python library?

前端 未结 1 609
轻奢々
轻奢々 2020-12-09 04:40

Is it possible to limit the download rate of GET requests using the requests Python library? For instance, with a command like this:

r = request         


        
相关标签:
1条回答
  • 2020-12-09 05:13

    There are several approaches to rate limiting; one of them is token bucket, for which you can find a recipe here and another one here.

    Usually you would want to do throttling or rate limiting on socket.send() and socket.recv(). You could play with socket-throttle and see if it does what you need.


    This is not to be confused with x-ratelimit rate limiting response headers, which are related to a number of requests rather than a download / transfer rate.

    0 讨论(0)
提交回复
热议问题