Last active
July 12, 2016 15:33
-
-
Save BrentonEarl/31d5968821fad94b0fab05bf9ce61ba8 to your computer and use it in GitHub Desktop.
Makes use of ruby nokogiri to get your public ip by scrapingf duckduckgo.com. Writes results to /tmp and prints it out.
This file contains 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 'rubygems' | |
require 'nokogiri' | |
require 'open-uri' | |
page = Nokogiri::HTML(open("https://duckduckgo.com/html/?q=what%20is%20my%20ip", proxy: "")) | |
@text = page.css('div#zero_click_abstract')[0].text.strip | |
open('/tmp/whatismyip', 'w') do |f| | |
f.puts @text | |
end | |
puts @text |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output
$ whatismyip.rb
Your IP address is 111.222.333.444 in Some City, Some State, United States (zipcode)