I'm creating a Python (using urllib2
) parser of addresses with non-english characters in it. The goal is to find coordinates of every address.
When I open this url in Firefox:
http://maps.google.com/maps/geo?q=Czech%20Republic%2010000%20Male%C5%A1ice&output=csv
it is converted (changes in address box) to
http://maps.google.com/maps/geo?q=Czech Republic 10000 Malešice&output=csv
and returns
200,6,50.0865113,14.4918052
which is a correct result.
However, if I open the same url (encoded, with %20 and such) in urllib2
(or Opera browser), the result is
200,4,49.7715220,13.2955410
which is incorrect. How can I open the first url in urllib2
to get the "200,6,50.0865113,14.4918052
" result?
Edit:
Code used
import urllib2
psc = '10000'
name = 'Malešice'
url = 'http://maps.google.com/maps/geo?q=%s&output=csv' % urllib2.quote('Czech Republic %s %s' % (psc, name))
response = urllib2.urlopen(url)
data = response.read()
print 'Parsed url %s, result %s\n' % (url, data)
output
Parsed url http://maps.google.com/maps/geo?q=Czech%20Republic%2010000%20Male%C5%A1ice&output=csv, result 200,4,49.7715220,13.2955410