Class: MMonitor::Strategies::Lefeng
- Defined in:
- lib/mmonitor/strategies/lefeng.rb
Overview
Instance Attribute Summary
Attributes inherited from Parser
Instance Method Summary collapse
- #css_path ⇒ Object
- #page_key ⇒ Object
- #pages ⇒ Object
-
#photo_url ⇒ Object
产品图片.
- #price ⇒ Object
-
#price_url ⇒ Object
产品售价图片(可选).
-
#provider ⇒ Object
输出的产品.
- #sku_id ⇒ Object
Methods inherited from Parser
#extra, #get_html, #initialize, #list, #page, #process, #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 24 25 26 |
# File 'lib/mmonitor/strategies/lefeng.rb', line 12 def css_path { body: 'body>div.mainBg>div.main>div.cont>div#clothList', list: 'div.smPruArea>div.makeup', item: 'div.pruwrap', total: 'div#sm-nav > span.tpages > span.tpageNum > i', pages: 'div#sm-nav > span.tpages > span.tpageNum > em', spu_id: 'id', sku_id: 'skuids', title: 'dl>dd.nam>a', photo_url: 'dl>dt>a>img', tag_price: 'dl>dd.pri>del', price_url: 'dl>dd.pri>img', } end |
#page_key ⇒ Object
32 33 34 |
# File 'lib/mmonitor/strategies/lefeng.rb', line 32 def page_key 'pageNo' end |
#pages ⇒ Object
28 29 30 |
# File 'lib/mmonitor/strategies/lefeng.rb', line 28 def pages self.body.at(css_path[:pages]).text.split('/')[1].to_i end |
#photo_url ⇒ Object
产品图片
44 45 46 |
# File 'lib/mmonitor/strategies/lefeng.rb', line 44 def photo_url # 产品图片 self.item.at(css_path[:photo_url])['pagespeed_lazy_src'] end |
#price ⇒ Object
36 37 38 |
# File 'lib/mmonitor/strategies/lefeng.rb', line 36 def price price_from_cart(spu_id, sku_id) || pirce_from_ocr(price_url) end |
#price_url ⇒ Object
产品售价图片(可选)
48 49 50 |
# File 'lib/mmonitor/strategies/lefeng.rb', line 48 def price_url # 产品售价图片(可选) self.item.at(css_path[:price_url])['pagespeed_lazy_src'].gsub('_73_', '_75_') end |
#provider ⇒ Object
输出的产品
8 9 10 |
# File 'lib/mmonitor/strategies/lefeng.rb', line 8 def provider :lefeng end |
#sku_id ⇒ Object
40 41 42 |
# File 'lib/mmonitor/strategies/lefeng.rb', line 40 def sku_id self.item.at('dl')[css_path[:sku_id]] end |