Nokogiriは実在するぶっ壊れたHTMLでもパースできるらしい。 Nokogiri.parseはヒューリスティックにHTMLかXMLかを判断して、合ったパーサを使うようになっている。でもHTMLだとわかっている場合はNokogiri::HTML.parseと明示したほうがよい。nokogiri.rbより引用。 module Nokogiri class << self ### # Parse an HTML or XML document. +string+ contains the document. def parse string, url = nil, encoding = nil, options = nil doc = if string =~ /^\s*<[^Hh>]*html/i # Probably html Nokogiri::HTML.parse(string,