ryoakg
10/18/2015 - 3:21 AM

クローラーに無視してらえる様に head > meta[name=robots] を書き換え

クローラーに無視してらえる様に head > meta[name=robots] を書き換え

require 'nokogiri'
open('xxx.html') {|f|
  break if doc.css('head').empty?
  meta=Nokogiri::XML::Node::new('meta', doc)
  meta['name']='robots'
  meta['content']='noindex,nofollow,noarchive'
  doc.css('head')[0].add_child(meta)
  
  open(output_filename, mode='w'){|f|
    html_str = doc.to_html(encoding: 'UTF-8')
    f.print html_str
  }  
}