Skip to content

Instantly share code, notes, and snippets.

@emergent
Created October 30, 2012 23:47
Show Gist options
  • Save emergent/3983870 to your computer and use it in GitHub Desktop.
Save emergent/3983870 to your computer and use it in GitHub Desktop.

Revisions

  1. emergent created this gist Oct 30, 2012.
    10 changes: 10 additions & 0 deletions mechanize_with_proxy_and_basicauth.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    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