Class: MMonitor::Crawler

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

Overview

爬虫,负责数据抓取流程

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ Crawler

Returns a new instance of Crawler.



9
10
11
12
13
# File 'lib/mmonitor/crawler.rb', line 9

def initialize(url)
      self.page = 1
  self.page_key = 'page'
  process(url)
end

Instance Attribute Details

#adapterObject

Returns the value of attribute adapter.



7
8
9
# File 'lib/mmonitor/crawler.rb', line 7

def adapter
  @adapter
end

#pageObject

Returns the value of attribute page.



7
8
9
# File 'lib/mmonitor/crawler.rb', line 7

def page
  @page
end

#page_keyObject

Returns the value of attribute page_key.



7
8
9
# File 'lib/mmonitor/crawler.rb', line 7

def page_key
  @page_key
end

#pagesObject

Returns the value of attribute pages.



7
8
9
# File 'lib/mmonitor/crawler.rb', line 7

def pages
  @pages
end

#paramsObject

Returns the value of attribute params.



7
8
9
# File 'lib/mmonitor/crawler.rb', line 7

def params
  @params
end

#totalObject

Returns the value of attribute total.



7
8
9
# File 'lib/mmonitor/crawler.rb', line 7

def total
  @total
end

#urlObject

Returns the value of attribute url.



7
8
9
# File 'lib/mmonitor/crawler.rb', line 7

def url
  @url
end

Instance Method Details

#itemsObject



15
16
17
# File 'lib/mmonitor/crawler.rb', line 15

def items
  self.adapter.items
end