Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save IvikGH/b0edb3aa872806c128df to your computer and use it in GitHub Desktop.
Save IvikGH/b0edb3aa872806c128df to your computer and use it in GitHub Desktop.
Using mechanize with proxy and basic auth
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