-
-
Save gr33n7007h/9cd6ee94e2e5be730df6436b4fdc4f8c to your computer and use it in GitHub Desktop.
foo
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
%w[resolv json open-uri socksify mechanize].map(&method(:require)) | |
Socksify.debug = true | |
def e_proxy | |
TCPSocket.socks_server = "31.146.173.85" | |
TCPSocket.socks_port = 1080 | |
end | |
def d_proxy | |
TCPSocket.socks_server = nil | |
TCPSocket.socks_port = nil | |
end | |
e_proxy | |
puts "proxy enabled" | |
Mechanize.start do |agent| | |
agent.get("http://www.ipchicken.com").parser.text.match(/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/) | |
puts "though mechanize #$1" | |
ip = JSON.parse(open("http://ipinfo.io").read)['ip'] | |
puts "through open-uri #{ip}" | |
end | |
d_proxy | |
puts "proxy disabled" | |
Mechanize.start do |agent| | |
agent.get("http://www.ipchicken.com").parser.text.match(/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/) | |
puts "through mechanize #$1" | |
ip = JSON.parse(open("http://ipinfo.io").read)['ip'] | |
puts "through open-uri #{ip}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment