Class: LoyalSpider::Clients::Xiaohuadi::ArticleEntity
- Inherits:
-
Object
- Object
- LoyalSpider::Clients::Xiaohuadi::ArticleEntity
- Includes:
- EntityAble, FetchAble
- Defined in:
- lib/loyal_spider/clients/xiaohuadi/article_entity.rb
Instance Method Summary collapse
Methods included from FetchAble
Methods included from EntityAble
Instance Method Details
#after_fetch_success(result) ⇒ Object
TODO
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/loyal_spider/clients/xiaohuadi/article_entity.rb', line 15 def after_fetch_success result # puts "after_fetch success: #{result}" entity_doc = result.response_html_doc.css('.listx') = self. _base_url = .base_url.to_s.strip # :content # 正文 # :tags # 标签 # :up_rating # 好评数 # :down_rating # 差评数目 # :comments_count # 评论数目 # :authors # 抓取的作者信息 _text_doc = entity_doc.css('.sonxltitle h1') self.title = "#{_text_doc.text}" _text_content = entity_doc.css('.sonxlarticle').first.inner_html _content = _text_content.split("<br>\r\n").map do |_cnt| "<p>#{Sanitize.clean _cnt}</p>" end.join('') self.content = _content _category_doc = entity_doc.css('.sonxlPosition a').last if _category_doc self. = [ { :text => _category_doc.text, :href => "#{self.base_url}#{_category_doc.attr('href')}" } ] else self. = [] end self. = [] self. = -1 self. = -1 self.comments_count = -1 end |