Site Accessibility Report with Raakt and Ruport

In this example SimpleCrawler can be used to crawl a website, test each page with the Ruby Accessibility Analysis Kit and format the result with Ruport. Please note that you must have a working installation of the Ruby programming language and the RubyGems package manager to use this code.

To be able to run this script you will need to install the simplecrawler, raakt and ruport gems first:

gem install simplecrawler
gem install raakt
gem install ruport

Answer yes to install all the required dependencies. Then, copy the code below to a file and save it e.g. as “test.rb”. Run it from the command line by typing ruby test.rb

Please note that Ruport has features to group data and output the result in a variety of formats including PDF. Please see the Ruport documentation for more information.

require 'rubygems'
require 'simplecrawler'
require 'raakt'
require 'ruport'
# Set up a new crawler
sc =[0])
sc.skip_patterns = ["\\.doc$", "\\.pdf$", "\\.xls$", "\\.pdf$", "\\.zip$"]
sc.maxcount = 100
report_data = :column_names => ["Url", "Error", "Details"]
sc.crawl { |document|
	if document.http_status and document.http_status[0] = "200"
		# Run basic accessibility check
		raakt =
		result = raakt.all
		puts "#{result.length}\t#{document.uri}"
		if result.length > 0
			for error in result
				report_data << [document.uri, error.eid.to_s, error.text]
		#report broken link
		report_data << [document.uri, "broken_link", ""]
#write report data to file (HTML table only...)"result.htm", "w") do |file|
	file << report_data.to_html
examples/accessibility-report.txt · Last modified: Y-m-d H:i by peterkz
Recent changes RSS feed, Powered by DokuWiki