nokogiri
インストール
$ sudo apt-get install libxml2 libxml2-dev libxslt1-dev
$ sudo gem install nokogiri
サンプル
require 'nokogiri'
require 'open-uri'
doc = Nokogiri::HTML(open('http://www.google.com/search?q=tenderlove'))
doc.css('h3.r a.l').each do |link|
puts link.content
end
タイトル取得
doc.css('title').first.content
よく使いそうなクラス
Nokogiri::XML::Node
Nokogiri::XML::Element
http://nokogiri.org/Nokogiri/XML/Node.html
CSS3セレクタ
http://zng.info/specs/css3-selectors.html#attribute-representation
参考: