Skip to content

Instantly share code, notes, and snippets.

@ridiculous
Created January 29, 2015 19:16
Show Gist options
  • Save ridiculous/56d0032b8ae71871bdfd to your computer and use it in GitHub Desktop.
Save ridiculous/56d0032b8ae71871bdfd to your computer and use it in GitHub Desktop.
USER_AGENT_ALIASES = ['Windows Mozilla', 'Mac Safari', 'Mac FireFox', 'Mac Mozilla', 'Linux Mozilla', 'Linux Firefox']
agent = Mechanize.new do |mech|
mech.open_timeout = 10
mech.read_timeout = 10
mech.follow_meta_refresh = true
mech.keep_alive = true
mech.max_history = 1
mech.user_agent_alias = USER_AGENT_ALIASES.sample
end
agent.set_proxy(proxy_ip, proxy_port, AppConfig.http_proxy.username, AppConfig.http_proxy.password)
agent.get(url)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment