Adrian Short 14 年之前
當前提交
66b8e2e51b
共有 1 個檔案被更改,包括 20 行新增0 行删除
  1. +20
    -0
      uk-postcodes.rb

+ 20
- 0
uk-postcodes.rb 查看文件

@@ -0,0 +1,20 @@
# Geocode a postcode & find councils/wards via uk-postcodes.com API

require 'rubygems'
require 'json'
require 'rest_client'
require 'pp'

postcode = "SW1A 0AA"
endpoint = "http://www.uk-postcodes.com/postcode/"

result = RestClient.get(endpoint + postcode.gsub(/ /, '') + '.json')

result_ary = JSON.parse(result)

puts "Lat:" + result_ary['geo']['lat'].to_s
puts "Lng:" + result_ary['geo']['lng'].to_s
puts "District: " + result_ary['administrative']['district']['title']
puts "Ward: " + result_ary['administrative']['ward']['title']

pp result_ary

Loading…
取消
儲存