Added ignore option to cli
This commit is contained in:
parent
19e022faae
commit
18eb31c0ce
|
@ -39,6 +39,7 @@ module Arachnid
|
|||
that responded with that code"
|
||||
option "-n", "--limit NUM", type: Int32, desc: "maximum number of pages to scan"
|
||||
option "-f", "--fibers NUM", type: Int32, desc: "maximum amount of fibers to spin up", default: 10
|
||||
option "-i", "--ignore PATTERNS", type: Array(String), desc: "url patterns to ignore (regex)"
|
||||
option "-o FILE", "--output=FILE", type: String, desc: "file to write the report to (if undefined \
|
||||
output will be printed to STDOUT"
|
||||
|
||||
|
@ -75,6 +76,7 @@ module Arachnid
|
|||
option "-o FILE", "--output=FILE", type: String, desc: "filename to write the report to. \
|
||||
default is the hostname + .json or .xml"
|
||||
option "-f", "--fibers NUM", type: Int32, desc: "maximum amount of fibers to spin up", default: 10
|
||||
option "-i", "--ignore PATTERNS", type: Array(String), desc: "url patterns to ignore (regex)"
|
||||
|
||||
run do |opts, args|
|
||||
if args.size != 1
|
||||
|
|
|
@ -18,6 +18,12 @@ module Arachnid
|
|||
spider = Arachnid::Agent.new(fibers: opts.fibers)
|
||||
spider.visit_urls_like(Regex.new(Regex.escape(url.to_s)))
|
||||
|
||||
opts.ignore.each do |pattern|
|
||||
pattern = Regex.new(pattern)
|
||||
pp pattern
|
||||
spider.ignore_urls_like(pattern)
|
||||
end
|
||||
|
||||
map = {
|
||||
domain: url.to_s,
|
||||
lastmod: {
|
||||
|
|
|
@ -15,6 +15,12 @@ module Arachnid
|
|||
spider.visit_urls_like(Regex.new(url))
|
||||
end
|
||||
|
||||
opts.ignore.each do |pattern|
|
||||
pattern = Regex.new(pattern)
|
||||
pp pattern
|
||||
spider.ignore_urls_like(pattern)
|
||||
end
|
||||
|
||||
pages = 0
|
||||
internal_links = Hash(String, Array(String)).new
|
||||
external_links = Hash(String, Array(String)).new
|
||||
|
|
Loading…
Reference in New Issue