Migrate modules using urllib2 to use phenny's web module
This commit is contained in:
@@ -17,10 +17,8 @@ def location(name):
|
||||
name = urllib.quote(name.encode('utf-8'))
|
||||
uri = 'http://ws.geonames.org/searchJSON?q=%s&maxRows=1' % name
|
||||
for i in xrange(10):
|
||||
u = urllib.urlopen(uri)
|
||||
if u is not None: break
|
||||
bytes = u.read()
|
||||
u.close()
|
||||
bytes = web.get(uri)
|
||||
if bytes is not None: break
|
||||
|
||||
results = web.json(bytes)
|
||||
try: name = results['geonames'][0]['name']
|
||||
|
||||
Reference in New Issue
Block a user