Class: Killshot::Crawler

Inherits:
Object
  • Object
show all
Defined in:
lib/killshot.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root, whitelist) ⇒ Crawler

Returns a new instance of Crawler.



12
13
14
15
# File 'lib/killshot.rb', line 12

def initialize(root, whitelist)
  @root      = root
  @whitelist = Set.new(whitelist)
end

Instance Attribute Details

#rootObject (readonly)

Returns the value of attribute root.



10
11
12
# File 'lib/killshot.rb', line 10

def root
  @root
end

#whitelistObject (readonly)

Returns the value of attribute whitelist.



10
11
12
# File 'lib/killshot.rb', line 10

def whitelist
  @whitelist
end

Instance Method Details

#crawl(&block) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'lib/killshot.rb', line 17

def crawl(&block)
  Anemone.crawl(root) do |anemone|
    anemone.on_every_page do |page|
      find_hotlinks(page) do |url, hotlink|
        block.call(url, hotlink)
      end
    end
  end
end