Files
metasploit-gs/lib/anemone/cli/serialize.rb
T
HD Moore b3cc6e19b6 Initial import of an Anemone snapshot
git-svn-id: file:///home/svn/framework3/trunk@10924 4d416f70-5f16-0410-b530-b9f4589650da
2010-11-06 04:34:43 +00:00

36 lines
812 B
Ruby

require 'anemone'
require 'optparse'
require 'ostruct'
begin
# make sure that the first option is a URL we can crawl
root = URI(ARGV[0])
rescue
puts <<-INFO
Usage:
anemone serialize [options] <url>
Synopsis:
Crawls a site starting at the given URL and saves the resulting
PageStore object to a file using Marshal serialization.
Options:
-o, --output filename Filename to save PageStore to. Defaults to crawl.{Time.now}
INFO
exit(0)
end
options = OpenStruct.new
options.output_file = "crawl.#{Time.now.to_i}"
# parse command-line options
opts = OptionParser.new
opts.on('-o', '--output filename') {|o| options.output_file = o }
opts.parse!(ARGV)
Anemone.crawl(root) do |anemone|
anemone.after_crawl do |pages|
open(options.output_file, 'w') {|f| Marshal.dump(pages, f)}
end
end