Skip to content

Instantly share code, notes, and snippets.

@mrsimo
Created December 22, 2008 17:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrsimo/39052 to your computer and use it in GitHub Desktop.
Save mrsimo/39052 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'spider' # sudo gem install spider
Spider.start_at('http://localhost/') do |s|
# Limit the pages to just this domain.
s.add_url_check do |a_url|
a_url =~ %r{^http://localhost.*}
end
# Handle 404s.
s.on 404 do |a_url, err_code|
puts "URL not found: #{a_url}"
end
# Handle 500s.
s.on 500 do |a_url, err_code|
puts "URL 500 error: #{a_url}"
end
# Handle 2xx.
s.on :success do |a_url, code, headers, body|
puts "URL OK: #{a_url}"
end
# Handle everything.
s.on :any do |a_url, resp|
puts "URL returned anything: #{a_url} with this code #{resp.code}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment