2010-10-02 41 views
2

我不理解如何使用海葵的触手部分。如果我正确地解释它,我觉得我可以使用它来仅从根部擦除特定的页面深度。海葵擦洗一定的页面深度

Anemone.crawl(start_url) do |anemone| 
    tentacle.new(i think but not working) 
    anemone.on_every_page do |page| 
     puts page.depth 
     puts page.url 
    end 
    end 

我想让它远离根深度3。

这里是RDoc的说什么

http://anemone.rubyforge.org/doc/index.html

Public Class methods 
new(link_queue, page_queue, opts = {}) 
Create a new Tentacle 

Public Instance methods 
run() 
Gets links from @link_queue, and returns the fetched Page objects into @page_queue 

谢谢

回答

4

得到它:)

Anemone.crawl(domain, :depth_limit => 1) do | anemone | 
    anemone.storage = Anemone::Storage.MongoDB 
    anemone.on_every_page do |page| 
     puts page.url 
     puts page.depth 

    end 
end