urllib2 rate limiting

Rob Wolfe rw at smsnet.pl
Thu Jan 10 13:28:11 EST 2008


Dimitrios Apostolou <jimis at gmx.net> writes:

> P.S. And something simpler: How can I disallow urllib2 to follow
> redirections to foreign hosts?

You need to subclass `urllib2.HTTPRedirectHandler`, override
`http_error_301` and `http_error_302` methods and throw
`urllib2.HTTPError` exception.

http://diveintopython.org/http_web_services/redirects.html

HTH,
Rob



More information about the Python-list mailing list