hpricot:An Hpricot Showcase:Hpricot Challenge:Getting the contents of a tag attribute?

まんま

>> require "hpricot"
=> true
>> doc = Hpricot('<a href="http://www.foo1.org/">foo1</a><a href="http://www.foo2.org/">foo2</a>')
=> #<Hpricot::Doc {elem <a href="http://www.foo1.org/"> "foo1" </a>} {elem <a href="http://www.foo2.org/"> "foo2" </a>}>
>> doc.search('a').first[:href]
=> "http://www.foo1.org/"
>> (doc/:a).first[:href]
=> "http://www.foo1.org/"
>> doc.at('a')[:href]
=> "http://www.foo1.org/"
>> (doc % :a)[:href]
=> "http://www.foo1.org/"