Skip to content

Instantly share code, notes, and snippets.

@cupnoodle
Created July 7, 2016 15:44
Show Gist options
  • Save cupnoodle/25326dd3d35c6a2d002e01ad84b9a7de to your computer and use it in GitHub Desktop.
Save cupnoodle/25326dd3d35c6a2d002e01ad84b9a7de to your computer and use it in GitHub Desktop.
Random legit user agent when web scraping
agent = Mechanize.new
# randomly choose one user agent aside from Mechanize itself
agent.user_agent = Mechanize::AGENT_ALIASES[(Mechanize::AGENT_ALIASES.keys - ['Mechanize']).sample]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment