Created
December 27, 2010 20:30
-
-
Save mkroman/756525 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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