Skip to content

Commit

Permalink
dfl
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Miessler committed Dec 7, 2009
0 parents commit 80136fd
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions geoip.rb
@@ -0,0 +1,20 @@
require 'rubygems'
require 'hpricot'
require 'open-uri'

file = File.open('/Users/daniel/Development/newfile', 'w')

File.open('/Users/daniel/Development/ips').each { |line|
doc = Hpricot(open("http://ipinfodb.com/ip_query.php?ip=#{line}"))
(doc/'response').each do|el|

ip = (el/'ip').inner_html
country = (el/'countryname').inner_html
state = (el/'regionname').inner_html
city = (el/'city').inner_html
puts "#{ip},#{country},#{state},#{city}"
file.puts "#{ip},#{country},#{state},#{city}"
file.flush
end

}

0 comments on commit 80136fd

Please sign in to comment.