Skip to content

Instantly share code, notes, and snippets.

@mru2
Last active December 22, 2015 22:18
Show Gist options
  • Save mru2/6538667 to your computer and use it in GitHub Desktop.
Save mru2/6538667 to your computer and use it in GitHub Desktop.
Simple ruby crawler for checking HTTP status codes
#!/usr/bin/env ruby
require 'rubygems'
require 'anemone'
require 'colorize'
entry = ARGV[0]
unless entry
puts "Please precise a point to start the crawl"
exit 1
end
Anemone.crawl(entry) do |anemone|
anemone.on_every_page do |page|
out = "#{page.code} : #{page.url}"
case (page.code / 100)
when 2
puts out.green
when 3
puts out.yellow
else
puts out.red
end
end
end
@mru2
Copy link
Author

mru2 commented Sep 12, 2013

Install :

curl -XGET https://gist.github.com/mru2/6538667/raw/35cc3cacc1b011ecd682254c49368d550417f207/gistfile1.txt > crawler
gem install anemone
gem install colorize
chmod +x crawler

Use :

./crawler http://starting-page-url.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment