Created
August 18, 2011 01:21
-
-
Save pauldruziak/1153073 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
| require 'mechanize' | |
| require 'tor' | |
| if Tor.available? | |
| agent = Mechanize.new do |agent| | |
| agent.user_agent_alias = 'Mac Safari' | |
| agent.set_proxy('localhost', 8118) | |
| agent.get('http://whatismyipaddress.com/') do |page| | |
| puts page.search("//input[@name='LOOKUPADDRESS']//@value").text | |
| puts page.search("//tr[th='City:']//td").text | |
| puts page.search("//tr[th='Region:']//td").text | |
| puts page.search("//tr[th='Country:']//td").text | |
| end | |
| end | |
| else | |
| puts 'Tor is unavailable' | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment