Skip to content Skip to sidebar Skip to footer

Timeout Error When Downloading .html Files From Urls

I get the following an error when downloading html pages from the urls. Error: raise URLError(err) urllib2.URLError:

Solution 1:

Well, since it doesn't happen to you most of the time, I can infer that your network is probably slow. Try to set the timeout in the following way:

req = urllib2.Request(site, headers=hdr)
timeout_in_sec = 360
page = urllib2.build_opener(urllib2.HTTPCookieProcessor).open(req, timeout=timeout_in_sec)
page_content = page.read()

Post a Comment for "Timeout Error When Downloading .html Files From Urls"