Sha256: 598204695ca62ed2aec017b97f03308ab9dd96a3b692e4450faa407e48551710
Contents?: true
Size: 1.31 KB
Versions: 3
Compression:
Stored size: 1.31 KB
Contents
class ReportCommand def self.start(opts) if opts[:output] options = opts.to_hash.delete_if { |k, v| v.nil?} options[:quiet] = !opts[:verbose] @crawler = CobwebCrawler.new({:cache_type => :full, :raise_exceptions => true}.merge(options)) columns = nil CSV.open(options[:output], "wb", :force_quotes => true) do |csv| statistics = @crawler.crawl(options[:url]) do |page| puts "Reporting on #{page[:url]}" @doc = page[:body] page["link_rel"] = scope.link_tag_with_rel("canonical")["href"] page["title"] = scope.head_tag.title_tag.contents page["description"] = scope.meta_tag_with_name("description")["content"] page["keywords"] = scope.meta_tag_with_name("keywords")["content"] page["img tag count"] = scope.img_tags.count page["scripts in body"] = scope.body_tag.script_tags.count page["img without alt count"] = scope.img_tags.select{|node| node[:alt].nil? || node[:alt].strip().empty?}.count page["img alt"] = scope.img_tags_with_alt.map{|node| node[:alt]}.uniq if !columns columns = page.keys.reject{|k| k==:body || k==:links} csv << columns.map{|k| k.to_s} end csv << columns.map{|k| page[k]} end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
cobweb-1.0.25 | lib/report_command.rb |
cobweb-1.0.24 | lib/report_command.rb |
cobweb-1.0.23 | lib/report_command.rb |