urllib IOError Exception

Bart Nessux bart_nessux at hotmail.com
Fri Jun 11 14:13:41 EDT 2004


JanC wrote:
> Bart Nessux <bart_nessux at hotmail.com> schreef:
> 
> 
>>        try:
>>           f = urllib2.urlopen("http://%s" %host)
>>        except urllib2.URLError:
>>           print host, "has no http server on  port 80"
>>
>>Anyway to speed this up??? The timeout per host is several minutes.
> 
> 
> socket.setdefaulttimeout(timeout)
> 
> <http://docs.python.org/lib/module-socket.html>
> 

Thanks, that worked... I find it odd that I have to import the socket 
module to set a timeout while using the urllib2 module... why isn't 
there a  function in urllib2 that can handle this?



More information about the Python-list mailing list