Sha256: d298deeb9e9fb48d6fd89be15389634e0e881a50f9359bf2174fa4751ccbc313
Contents?: true
Size: 1.03 KB
Versions: 8
Compression:
Stored size: 1.03 KB
Contents
#!/usr/bin/env ruby 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
8 entries across 8 versions & 1 rubygems