Sha256: ad98fdc883bd360047acd11178cb76a0e42bb9e3e339bee92fb2799942510f13
Contents?: true
Size: 920 Bytes
Versions: 7
Compression:
Stored size: 920 Bytes
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 params = if options[:images] { :tags => %w[div p img a], :attributes => %w[src href], :remove_empty_nodes => false, :debug => options[:debug] } else { :debug => options[:debug] } end puts Readability::Document.new(text, params).content
Version data entries
7 entries across 7 versions & 2 rubygems