python - Using urllib2.urlopen() to load a URL without waiting for a response -


i want send request don't want waste time waiting responses. because responses useless me. looked python doc didn't find solution. advice. have tried use urllib2.urlopen(url, timeout=0.02) can't sure if request sent out.

this called asynchronous loading, , here's blog post explaining how urllib2. sample code:

#!/usr/bin/env python  import urllib2 import threading  class myhandler(urllib2.httphandler):     def http_response(self, req, response):         print "url: %s" % (response.geturl(),)         print "info: %s" % (response.info(),)         l in response:             print l         return response  o = urllib2.build_opener(myhandler()) t = threading.thread(target=o.open, args=('http://www.google.com/',)) t.start() print "i'm asynchronous!" 

this load url without waiting response.


Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -