Module: SpiderCore::FollowDSL
- Included in:
- MicroSpider
- Defined in:
- lib/spider_core/follow_dsl.rb
Instance Attribute Summary collapse
-
#skip_followers ⇒ Object
Returns the value of attribute skip_followers.
Instance Method Summary collapse
Instance Attribute Details
#skip_followers ⇒ Object
Returns the value of attribute skip_followers.
4 5 6 |
# File 'lib/spider_core/follow_dsl.rb', line 4 def skip_followers @skip_followers end |
Instance Method Details
#follow(pattern, opts = {}, &block) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/spider_core/follow_dsl.rb', line 6 def follow(pattern, opts = {}, &block) return unless block_given? kind = opts[:kind] || :css actions << lambda { spider = self.spawn spider.learn(&block) scan_all(kind, pattern, opts).each do |element| next if skip_followers && skip_followers.include?(element[:href]) spider.skip_set_entrance = false spider.entrance(element[:href]) end current_location[:follow] ||= [] current_location[:follow] << spider.crawl[:results] } end |