自分自身のための ものづくり / 自分自身のためのものづくりメモ

* HTMLをXHTMLに変換してREXMLで処理

プログラム(抜粋)
h = Html2xhtml.new
h.read_array(readlines)

require "rexml/document"
y = REXML::Document.new(h.body.to_s)

y.elements["/html/body"].elements[6, 'table'].elements['tr/td'].elements.each('a') do |a|
    p a.attributes['href']
    print a.text.strip + "\n"
end
結果
"http://auctions.yahoo.co.jp/jp/0-category.html?"
オークション
"http://list3.auctions.yahoo.co.jp/jp/23336-category.html?"
コンピュータ
"http://list3.auctions.yahoo.co.jp/jp/2084039759-category.html?"
パーソナルコンピュータ
楽だ…めっちゃ楽だ…

#Web #ヤフオク

create : 2006/06/01 (Thu)
update : 2006/06/01 (Thu)