Skip to content

Instantly share code, notes, and snippets.

@craigw
Created October 11, 2011 19:21
Show Gist options
  • Save craigw/1279113 to your computer and use it in GitHub Desktop.
Save craigw/1279113 to your computer and use it in GitHub Desktop.
#! /usr/bin/env ruby
require 'mechanize'
unless ARGV.size >= 2
puts "#{File.basename($0)} <site-url> <user agent header>"
exit 1
end
site = ARGV.shift
user_agent = ARGV.join ' '
a = Mechanize.new { |agent|
agent.user_agent = user_agent
}
page = a.get(site)
puts site
rand(100).times do
link = page.links.to_a.sort_by{rand}[0]
puts link.href
page = a.click link
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment