I'm currently assigning random proxies to requests via a custom middleware. I'd like to key download throttling to the specific proxy that the request is using, but as far as I can tell, out of the box, this is only possible when tied to domains or IPs. I'm worried that implementing pooling logic in the proxy middleware would cause thread safety issues. Has anyone done this before? Any pointers would be appreciated.
相关问题
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- How to get the background from multiple images by
- Evil ctypes hack in python
- Correctly parse PDF paragraphs with Python
As recommended on the Scrapy mailing list, there is a special request meta variable that the Autothrottle middleware obeys, called
download_slot
- this allows for programmatic grouping/throttling of requests.In my custom proxy middleware:
I use the hash function as a cheap way to bucket the requests by an externally defined limit on requests.