urllib.urlopen works nonetheless urllib2.urlopen doesn't
i have rudimentary website i'm testing. it's controlling localhost i opening web browser. index page simply "running". urllib.urlopen successfully review page nonetheless urllib2.urlopen not. here's book demonstrates problem (this tangible book simplification opposite exam script):
import urllib, urllib2
print urllib.urlopen("http://127.0.0.1").read() # prints "running"
print urllib2.urlopen("http://127.0.0.1").read() # throws an exception
here's smoke-stack trace:
traceback (most new last):
record "urltest.py", line 5, <module>
imitation urllib2.urlopen("http://127.0.0.1").read()
record "c:\python25\lib\urllib2.py", line 121, urlopen
relapse _opener.open(url, data)
record "c:\python25\lib\urllib2.py", line 380, open
response = meth(req, response)
record "c:\python25\lib\urllib2.py", line 491, http_response
'http', request, response, code, msg, hdrs)
record "c:\python25\lib\urllib2.py", line 412, error
outcome = self._call_chain(*args)
record "c:\python25\lib\urllib2.py", line 353, _call_chain
outcome = func(*args)
record "c:\python25\lib\urllib2.py", line 575, http_error_302
relapse self.parent.open(new)
record "c:\python25\lib\urllib2.py", line 380, open
response = meth(req, response)
record "c:\python25\lib\urllib2.py", line 491, http_response
'http', request, response, code, msg, hdrs)
record "c:\python25\lib\urllib2.py", line 418, error
relapse self._call_chain(*args)
record "c:\python25\lib\urllib2.py", line 353, _call_chain
outcome = func(*args)
record "c:\python25\lib\urllib2.py", line 499, http_error_default
lift httperror(req.get_full_url(), code, msg, hdrs, fp)
urllib2.httperror: http blunder 504: gateway timeout
any ideas? i competence finish adult wanting some-more modernized comforts urllib2, i don't wish only review controlling urllib, and i wish know problem.
Comments
Post a Comment