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