Skip to content

Instantly share code, notes, and snippets.

@mkroman
Created December 27, 2010 20:30
Show Gist options
  • Select an option

  • Save mkroman/756525 to your computer and use it in GitHub Desktop.

Select an option

Save mkroman/756525 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# encoding: utf-8
require 'json'
require 'net/http'
module Google
class Location
def self.search address
new(mac: address).search
end
def initialize options
@options = options
end
def search
res = nil
Net::HTTP.start 'www.google.com', 80 do |http|
post = Net::HTTP::Post.new '/loc/json'
res = http.request(post, request_body.to_json)
end
res
end
private
def request_body
puts "searching for #{@options[:mac]} …"
{ host: "maero.dk", version: "1.1.0", request_address: true, wifi_towers: [{ mac_address: @options[:mac], ssid: "g", signal_strength: -72 }] }
end
end
end
p Google::Location.search("30:46:9a:7a:69:44").body
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment