fixed geocode, issue 855, thanks niphllod

This commit is contained in:
mdipierro
2012-06-17 23:36:35 -05:00
parent 90883e5926
commit 71f43c0669
2 changed files with 3 additions and 4 deletions
+1 -1
View File
@@ -1 +1 @@
Version 2.00.0 (2012-06-17 23:35:00) dev
Version 2.00.0 (2012-06-17 23:36:32) dev
+2 -3
View File
@@ -3567,13 +3567,12 @@ def fetch(url, data=None, headers=None,
return html
regex_geocode = \
re.compile('\<coordinates\>(?P<la>[^,]*),(?P<lo>[^,]*).*?\</coordinates\>')
re.compile(r"""<geometry>[\W]*?<location>[\W]*?<lat>(?P<la>[^<]*)</lat>[\W]*?<lng>(?P<lo>[^<]*)</lng>[\W]*?</location>""")
def geocode(address):
try:
a = urllib.quote(address)
txt = fetch('http://maps.google.com/maps/geo?q=%s&output=xml'
txt = fetch('http://maps.googleapis.com/maps/api/geocode/xml?sensor=false&address=%s'
% a)
item = regex_geocode.search(txt)
(la, lo) = (float(item.group('la')), float(item.group('lo')))