开发者

Python urllib2 and connection refused on google maps geocoding

开发者 https://www.devze.com 2023-03-14 04:23 出处:网络
I am doing a simple geocoding of addresses using Google maps api. Here is a snipped and getting a \"[Errno 61] Connection refused\":

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号