Class: MMonitor::Strategies::Yixun

Inherits:
Parser
  • Object
show all
Defined in:
lib/mmonitor/strategies/yixun.rb

Overview

Instance Attribute Summary

Attributes inherited from Parser

#body, #item, #items

Instance Method Summary collapse

Methods inherited from Parser

#extra, #get_html, #initialize, #list, #page, #page_key, #price, #price_url, #process, #sku_id, #spu_id, #tag_price, #title, #total

Constructor Details

This class inherits a constructor from MMonitor::Parser

Instance Method Details

#css_pathObject



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/mmonitor/strategies/yixun.rb', line 12

def css_path
  {
    body:      'div#container > div > div.grid_m.smain > div.grid_m_inner',
    list:      'div.goods > ul#itemList',
    item:      'li.goods_li',
    total:     '#list > div.sort_page > div.sort_page_txt > b',
    pages:     '#list > div.sort_page > div.sort_page_num > span', # .text.split('/')[1]
    spu_id:    'commid',
    title:     'div > div.mod_goods_info > p.mod_goods_tit > a',
    photo_url: 'div > div.mod_goods_img > a > img', # 'data-ks-lazyload'
    price:     'div > div.mod_goods_info > p.mod_goods_price > span.mod_price > span'
  }
end

#pagesObject



30
31
32
# File 'lib/mmonitor/strategies/yixun.rb', line 30

def pages
  self.body.at(css_path[:pages]).text.split('/')[1].to_i
end

#photo_urlObject

产品图片



26
27
28
# File 'lib/mmonitor/strategies/yixun.rb', line 26

def photo_url # 产品图片
  self.item.at(css_path[:photo_url])['init_src']
end

#providerObject

输出的产品



8
9
10
# File 'lib/mmonitor/strategies/yixun.rb', line 8

def provider
  :yixun
end