Skip to content

Instantly share code, notes, and snippets.

@axgle
Created February 10, 2010 08:14
Show Gist options
  • Save axgle/300121 to your computer and use it in GitHub Desktop.
Save axgle/300121 to your computer and use it in GitHub Desktop.
require 'net/http'
require "uri"
def ip2addr(ip="google.com")
url=URI.parse("http://ip138.com/ips8.asp")
res=Net::HTTP.post_form(url,:ip=>ip,:action=>2)
res.body.scan(/<ul class="ul1">(.*)<\/ul>/).to_s.scan(/<li>(.*?)<\/li>/)
end
puts ip2addr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment