Class: LoyalSpider::Clients::KuaileMahua::ArticleEntity
- Inherits:
-
Object
- Object
- LoyalSpider::Clients::KuaileMahua::ArticleEntity
- Includes:
- EntityAble, FetchAble
- Defined in:
- lib/loyal_spider/clients/kuaile_mahua/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 |
# File 'lib/loyal_spider/clients/kuaile_mahua/article_entity.rb', line 15 def after_fetch_success result # puts "after_fetch success: #{result}" html_doc = result.response_html_doc entity_doc = html_doc.css('.main .main-left .xiaohua .xiaohua-data') self.title = entity_doc.css('h1').first.text.to_s.strip self.content = entity_doc.css('.content').inner_html self. = entity_doc.css('.link .tags h4 a').map do |_tag_doc| { :text => _tag_doc.text.to_s.strip, :href => "#{self.base_url}#{_tag_doc.attr('href').to_s.strip}" } end self. = entity_doc.css('.link .tags .pusher a').map do || { :text => .text.to_s.strip, :href => "#{.attr('href').to_s.strip}" } end self. = entity_doc.css('.tools li a.good').text.to_i self. = entity_doc.css('.tools li a.bad').text.to_i self.comments_count = entity_doc.css('.tools li s').first.text.to_i end |