Migrate modules using urllib2 to use phenny's web module

This commit is contained in:
mutantmonkey
2011-09-21 20:43:05 -04:00
parent c8fe22190c
commit f34695717d
4 changed files with 44 additions and 51 deletions

View File

@@ -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']