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, attr: :href, **opts, &block) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/spider_core/follow_dsl.rb', line 6 def follow(pattern, attr: :href, **opts, &block) return unless block_given? actions << lambda { spider = self.spawn spider.learn(&block) scan_all(pattern, opts).each do |element| next if skip_followers && skip_followers.include?(element[:href]) spider.skip_set_entrance = false spider.entrance(element[attr]) end put( "follow::#{pattern}", spider.crawl ) } end |