2008-12-03から1日間の記事一覧

htree + rexml で フル XPathを使う

htree は柔軟というかpermissiveだと謳われているのでスクレイピングにはちょうどよさげ。 hpricotは全然xpathをサポートしていなかったのでこのhtree+rexmlを使う。 require "rexml/document" require 'htree' doc = HTree('<div><p>abc</p><div><p>def</p><p>ghi</p></div><p>jkl</p></div>').to_rexml names …

htree を OSX にインストールするときにこけた

htreeはxmlやhtmlをparseするための rubyのライブラリらしい。 ruby install.rb とやったらば、 install.rb:19:in `target_directory': could not find target install directory (RuntimeError) となってこけた。ruby初心者なのでよくわからないけど、 def …

Ruby REXML XPath バグ

REXMLのXPathを使ってみたが、今のところあまり使えない。作者いわく: Some of the XPath functions are untested8. Any XPath functions that don't work are also bugs... please report them. If you send a unit test that illustrates the problem, I'…