NokogiriがダメだったのでHpricotをインストールした

2014年1月4日
1 分

タイトルのとおり。Hpricot はすんなりインストールできた。

^o^ > gem install hpricot
Fetching: hpricot-0.8.6.gem (100%)
Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
Successfully installed hpricot-0.8.6
Parsing documentation for hpricot-0.8.6
unable to convert "\x90" from ASCII-8BIT to UTF-8 for lib/fast_xs.so, skipping
unable to convert "\x90" from ASCII-8BIT to UTF-8 for lib/hpricot_scan.so, skipp
ing
Installing ri documentation for hpricot-0.8.6
1 gem installed

でも、もともと Hpricot を使ってたのを Nokogiri に乗り換えたんだよなあ。

一応、簡単なスクリプトを書いてちゃんと動くかどうか試してみよう。

require 'hpricot'

HTML =<<

Hello, world. This is <a href="http://blog.panicblanket.com/">blog.PanicBlanket.com</a>

EOH

doc = Hpricot(HTML)
links = doc.search("a")
puts links[0]["href"]

実行結果:

^o^ > ruby hpricot_test.rb
http://blog.panicblanket.com/

うまくいってるようだ。