Sha256: 5ef1eb91151d9e2c7c6cce45fa36e193ea1c7729b6beaec024f3f4d4dcf1b3da
Contents?: true
Size: 1.03 KB
Versions: 9
Compression:
Stored size: 1.03 KB
Contents
#!/usr/bin/env ruby require 'rubygems' require 'open-uri' require 'optparse' require File.dirname(__FILE__) + '/../lib/dq-readability' options = { :debug => false, :images => false } options_parser = OptionParser.new do |opts| opts.banner = "Usage: #{File.basename($0)} [options] URL" opts.on("-d", "--debug", "Show debug output") do |v| options[:debug] = v end opts.on("-i", "--images", "Keep images and links") do |i| options[:images] = i end opts.on_tail("-h", "--help", "Show this message") do puts opts exit end end options_parser.parse! if ARGV.length != 1 STDERR.puts options_parser exit 1 end text = open(ARGV.first).read if options[:images] puts Readability::Document.new(text, :tags => %w[div p img a], :attributes => %w[src href], :remove_empty_nodes => false, :debug => options[:debug]).content else puts Readability::Document.new(text, :debug => options[:debug]).content end
Version data entries
9 entries across 9 versions & 1 rubygems