Skip to content

Instantly share code, notes, and snippets.

@pauldruziak
Created August 18, 2011 01:21
Show Gist options
  • Select an option

  • Save pauldruziak/1153073 to your computer and use it in GitHub Desktop.

Select an option

Save pauldruziak/1153073 to your computer and use it in GitHub Desktop.
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