Skip to content

Instantly share code, notes, and snippets.

@yswallow
Created December 2, 2012 03:07
Show Gist options
  • Save yswallow/4186756 to your computer and use it in GitHub Desktop.
Save yswallow/4186756 to your computer and use it in GitHub Desktop.
Nokogiriの文字化け対策
require 'nokogiri'
require 'open-uri'
require 'kconv'
url = ARGV[0] ? ARGV[0].chomp : "http://blogs.yahoo.co.jp/ikedadamu/6739054.html"
encode = ARGV[1] ? ARGV[1].chomp : nil
page = Nokogiri::HTML(open(url),encode)
puts page.to_html.toutf8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment