Created
July 30, 2016 21:49
-
-
Save pry0cc/6646eb3b345c4cf7490f3d152e4b1ac5 to your computer and use it in GitHub Desktop.
A snappy application to find out everything known about an IP.
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 | |
require 'json' | |
require 'mechanize' | |
require 'rubygems' | |
require 'open-uri' | |
puts "Looking up #{ARGV[0]}" | |
agent = Mechanize.new | |
data = agent.get("http://freegeoip.net/json/#{ARGV[0]}").body | |
json = JSON.parse(data) | |
agent.user_agent = "curl/7.50.0" | |
weather = agent.get("http://wttr.in/#{json["city"]}").body.split("\n") | |
puts "Country Code: " + json["country_code"] | |
puts "Country: " + json["country_name"] | |
puts "Region Code: " + json["region_code"] | |
puts "Region Name: " + json["region_name"] | |
puts "City: " + json["city"] | |
puts "Zip Code: " + json["zip_code"] | |
puts "Time Zone: " + json["time_zone"] | |
puts "Metro Code: " + json["metro_code"].to_s | |
puts "Google Maps: https://www.google.com/maps?z=12&t=m&q=loc:#{json["latitude"]}+#{json["longitude"]}" | |
puts "Weather right now: " | |
puts weather[1..6] | |
puts "" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment