Class: JianshuSyncer

Inherits:
PerNodeSyncer show all
Defined in:
lib/syncers/jianshu_syncer.rb

Constant Summary

Constants included from NodeAttrModule

NodeAttrModule::ATTRS

Instance Method Summary collapse

Methods inherited from PerNodeSyncer

#gen_html, #get_article_nodes

Methods included from NodeAttrModule

remove_common_attr

Methods inherited from AbstractSyncer

#_fetch_html, #gen_html, #get_article_nodes, #initialize

Constructor Details

This class inherits a constructor from AbstractSyncer

Instance Method Details

#_handle_node(node) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/syncers/jianshu_syncer.rb', line 10

def _handle_node(node)
  case node.name
  when 'div'
    img_node = node.css('img')[-1]
    if img_node
      node = img_node
      # jianshu.com uses a //<url> style, therefore 
      # append an 'https' in front of '//' part to 
      # make it a valid image url.
      node['src'] = 'https:' + node['data-original-src']
    end
  end

  node.to_html
end

#get_article_xpathObject



6
7
8
# File 'lib/syncers/jianshu_syncer.rb', line 6

def get_article_xpath
  '//article'
end