Sha256: b684bb2f88cbd9479c4e7aed776c72b5fb201644f1f6f73b2e30ffe21a927811
Contents?: true
Size: 1.04 KB
Versions: 5
Compression:
Stored size: 1.04 KB
Contents
#!/usr/bin/env ruby $KCODE='u' require 'rubygems' require 'open-uri' require 'optparse' require File.dirname(__FILE__) + '/../lib/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
5 entries across 5 versions & 2 rubygems