KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I get a strange error when using urllib: INFO 2011-12-07 07:02:45,101 main.py:884] urlhttp://maps.googleapis.com/maps/api/geocode/json?latlng=59.3333,18.05&sensor=false WARNING 2011-12-07 07:02:45,103 urlfetch_stub.py:428] Stripped prohibited headers from URLFetch request: ['Host'] ERROR 2011-12-07 07:02:45,210 main.py:346] HTTPResponse instance has no attribute 'readline': Traceback (most recent call last): File "/media/Lexar/montao/lib/webapp2/webapp2.py", line 545, in dispatch return method(*args, **kwargs) File "/media/Lexar/montao/montaoproject/main.py", line 885, in get jsondata = json.load(urllib2.urlopen(url)) File "/usr/lib/python2.7/urllib2.py", line 126, in urlopen return _opener.open(url, data, timeout) File "/usr/lib/python2.7/urllib2.py", line 391, in open response = self._open(req, data) File "/usr/lib/python2.7/urllib2.py", line 409, in _open '_open', req) File "/usr/lib/python2.7/urllib2.py", line 369, in _call_chain result = func(*args) File "/usr/lib/python2.7/urllib2.py", line 1185, in http_open return self.do_open(httplib.HTTPConnection, req) File "/usr/lib/python2.7/urllib2.py", line 1176, in do_open resp = addinfourl(fp, r.msg, req.get_full_url()) File "/media/Lexar/montao/google/appengine/dist27/urllib.py", line 978, in __init__ addbase.__init__(self, fp) File "/media/Lexar/montao/google/appengine/dist27/urllib.py", line 926, in __init__ self.readline = self.fp.readline AttributeError: HTTPResponse instance has no attribute 'readline' The code that used to work is url = 'http://maps.googleapis.com/maps/api/geocode/json' + \ '?latlng={},{}&sensor=false'.format(entity.geopt.lat, entity.geopt.lon) logging.info('url%s' % url) jsondata = json.load(urllib2.urlopen(url)) Could you tell me what's wrong here? I read somewhere that the response object does not have a "get" method then how come it
Tags (comma-separated)
Save Edits
Cancel