Class: SpiderBot::Base

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

Class Method Summary collapse

Class Method Details

.auto(&block) ⇒ Object

execute method with command "spider start" and "spider crawl"



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/spider_bot/base.rb', line 8

def auto &block
  if defined?(BOTCONSOLE)
    klass = Class.new do
      def origin url, options = {}
        @origin_url = url
        @origin_options = options
      end
  
      def execute name = nil, &block
        crawl_instance = Crawl.new(@origin_url, @origin_options)
        crawl_instance.instance_eval &block
      end
    end
    klass.allocate.instance_eval &block
  end
end

.crawl(url, options = {}) ⇒ Object



25
26
27
28
# File 'lib/spider_bot/base.rb', line 25

def crawl url, options = {}
  crawl_instance = Crawl.new(url, options)
  crawl_instance.crawl_data
end