I am doing a simple geocoding of addresses using Google maps api.
Here is a snipped and getting a "[Errno 61] Connection refused":
import urllib2
url='http://maps.googleapis.com/maps/api/geocode/json?address=800+S.+Pacific+Coast+Hwy,+Redondo+Beach,+CA&sensor=false'
req = urllib2.Request(url)
print vars(req)
response=urllib2.urlopen(req)
the_page = response.read()
It works from just doing a GET in FF 3 browser
php version works fine:
$url='http://maps.googleapis.com/maps/api/geocode/json?address=800+S.+Pacific+Coast+Hwy,+Redondo+Beach,+CA&sensor=false';
$result=file_get_contents($url);
var_dump($result);
and ruby works too:
require 'net/http'
host='maps.googleapis.com'
path='/maps/api/geocode/json?address=800+S.+Pacific+Coast+Hwy,+Redondo+Beach,+CA&sensor=false'
http=Net::HTTP.new(host)
headers,body=http.get(path)
if headers.code=="200"
开发者_运维问答 print body
else
puts "#{headers.code} #{headers.message}"
end
Any ideas why the python version doesn't work?
Code is fine. I think you just exceed: Google geocoding limits
精彩评论