Skip to content

Instantly share code, notes, and snippets.

@ryoakg
Last active October 24, 2015 04:06
Show Gist options
  • Save ryoakg/b2844412a08ec8280031 to your computer and use it in GitHub Desktop.
Save ryoakg/b2844412a08ec8280031 to your computer and use it in GitHub Desktop.
クローラーに無視してらえる様に 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
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment