Sha256: 7ae33e27a93b39a1c3b381de7da5902865314cee89871592ff1824debf610578
Contents?: true
Size: 854 Bytes
Versions: 2
Compression:
Stored size: 854 Bytes
Contents
#!/usr/bin/env ruby require "recipe_crawler" require "optparse" options = { limit: 1, url: nil, interval_time: 0 } # Parse options optparser = OptionParser.new do |opts| opts.on("-n", "--number x", Integer, "Number of recipes to fetch") { |x| options[:number] = x} opts.on("-u", "--url url", String, "URL of a recipe to fetch") { |x| options[:url] = x} opts.on("-i", "--interval_time x", Integer, "Wainting time between requests") { |x| options[:interval_time] = x} opts.parse!(ARGV) end # check if url is set if options[:url] # Instanciate the crawler r = RecipeCrawler::Crawler.new options[:url] # crawl and display recipe fetched r.crawl!(options[:number], options[:interval_time]) do |recipe| puts "[x] #{recipe.title} fetched!" end else raise OptionParser::MissingArgument, 'You need to specify a start url.' end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
recipe_crawler-4.0.0 | bin/recipe_crawler |
recipe_crawler-3.1.2 | bin/recipe_crawler |