Sha256: 885d300305127f3aa959803246e74c9fdc728031159f25fa5c9d0a92441e914e

Contents?: true

Size: 1.14 KB

Versions: 26

Compression:

Stored size: 1.14 KB

Contents

#!/usr/bin/env ruby
require 'optparse'
require 'open-uri'
require 'irb'
require 'uri'
require 'rubygems'
require 'nokogiri'

parse_class = Nokogiri
encoding = nil

opts = OptionParser.new do |opts|
  opts.banner = "Nokogiri: an HTML, XML, SAX, and Reader parser"
  opts.define_head "Usage: nokogiri <uri|path> [options]"
  opts.separator ""
  opts.separator "Examples:"
  opts.separator "  nokogiri http://www.ruby-lang.org/"
  opts.separator "  nokogiri ./public/index.html"
  opts.separator ""
  opts.separator "Options:"

  opts.on("--type [TYPE]", [:xml, :html]) do |v|
    parse_class = {:xml => Nokogiri::XML, :html => Nokogiri::HTML}[v]
  end

  opts.on("-E", "--encoding encoding", "Read as encoding (default #{encoding})") do |v|
    encoding = v
  end

  opts.on_tail("-?", "--help", "Show this message") do
    puts opts
    exit
  end

  opts.on_tail("-v", "--version", "Show version") do
    require 'yaml'
    puts Nokogiri::VERSION_INFO.to_yaml
    exit
  end
end
opts.parse!

uri = ARGV.shift

if uri.to_s.strip.empty?
  puts opts
  exit 1
end

@doc = parse_class.parse(open(uri).read, nil, encoding)

puts "Your document is stored in @doc..."
IRB.start

Version data entries

26 entries across 26 versions & 4 rubygems

Version Path
domo-0.0.4 vendor/bundle/ruby/1.9.1/gems/nokogiri-1.4.4/bin/nokogiri
nokogiri-1.4.7-java bin/nokogiri
nokogiri-1.4.7-x86-mingw32 bin/nokogiri
nokogiri-1.4.7-x86-mswin32-60 bin/nokogiri
nokogiri-1.4.7 bin/nokogiri
search_biomodel-1.0.0 search_biomodel/ruby/1.8/gems/nokogiri-1.4.6/bin/nokogiri
nokogiri-1.4.6 bin/nokogiri
nokogiri-1.4.6-java bin/nokogiri
nokogiri-1.4.6-x86-mingw32 bin/nokogiri
nokogiri-1.4.6-x86-mswin32-60 bin/nokogiri
nokogiri-1.4.5-java bin/nokogiri
nokogiri-1.4.5 bin/nokogiri
nokogiri-1.4.5-x86-mswin32-60 bin/nokogiri
nokogiri-1.4.5-x86-mingw32 bin/nokogiri
nokogiri-1.5.0.beta.4 bin/nokogiri
nokogiri-1.5.0.beta.4-java bin/nokogiri
nokogiri-backupify-1.5.0.beta.4 bin/nokogiri
nokogiri-1.5.0.beta.3-java bin/nokogiri
nokogiri-1.5.0.beta.3 bin/nokogiri
nokogiri-1.4.4.2-java bin/nokogiri