Created
October 11, 2011 19:21
-
-
Save craigw/1279113 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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