Class: MMonitor::Strategies::Tmall
- Defined in:
- lib/mmonitor/strategies/tmall.rb
Overview
Instance Attribute Summary
Attributes inherited from Parser
Instance Method Summary collapse
- #css_path ⇒ Object
- #page_key ⇒ Object
- #pages ⇒ Object
-
#photo_url ⇒ Object
产品图片.
-
#provider ⇒ Object
输出的产品.
Methods inherited from Parser
#extra, #get_html, #initialize, #list, #page, #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_path ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/mmonitor/strategies/tmall.rb', line 12 def css_path { body: '#TmshopSrchNav>div', list: 'div.J_TItems', item: 'dl.item', pages: 'div.filter.clearfix.J_TFilter > p > b.ui-page-s-len', # .text.split('/')[1] spu_id: 'data-id', title: 'dd.detail > a', photo_url: 'dt > a:nth-child(1) > img', # 'data-ks-lazyload' price: 'dd.detail > div > div.cprice-area > span.c-price' } end |
#page_key ⇒ Object
33 34 35 |
# File 'lib/mmonitor/strategies/tmall.rb', line 33 def page_key 'pageNo' end |
#pages ⇒ Object
29 30 31 |
# File 'lib/mmonitor/strategies/tmall.rb', line 29 def pages self.body.at(css_path[:pages]).text.split('/')[1].to_i end |
#photo_url ⇒ Object
产品图片
25 26 27 |
# File 'lib/mmonitor/strategies/tmall.rb', line 25 def photo_url # 产品图片 self.item.at(css_path[:photo_url])['data-ks-lazyload'] end |
#provider ⇒ Object
输出的产品
8 9 10 |
# File 'lib/mmonitor/strategies/tmall.rb', line 8 def provider :tmall end |