Created
October 30, 2012 23:47
-
-
Save emergent/3983870 to your computer and use it in GitHub Desktop.
Using mechanize with proxy and basic auth
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 'rubygems' | |
require 'mechanize' | |
agent = Mechanize.new | |
agent.set_proxy('proxy.example.com', 80, 'username', 'password') | |
agent.add_auth('http://hoge.com','b_username','b_password') | |
agent.user_agent_alias = "Windows Mozilla" | |
res = agent.get('http://hoge.com/some/page') | |
puts res.body |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
how would you test the connection to the proxy before setting it?