How come I get a timed-out when I try to download something off my own domain?
Posted
by alex
on Stack Overflow
See other posts from Stack Overflow
or by alex
Published on 2010-04-03T00:51:09Z
Indexed on
2010/04/03
0:53 UTC
Read the original article
Hit count: 389
def download(source_url):
socket.setdefaulttimeout(10)
agents = ['Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0)','Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 5.1)','Microsoft Internet Explorer/4.0b1 (Windows 95)','Opera/8.00 (Windows NT 5.1; U; en)']
ree = urllib2.Request(source_url)
ree.add_header('User-Agent',random.choice(agents))
resp = urllib2.urlopen(ree)
htmlSource = resp.read()
return htmlSource
url = "http://myIP/details/?id=4"
result_html = download(url)
It shouldn't time out...even with the 10 second timeout..
© Stack Overflow or respective owner