8
對於以下HTML,我想解析它並使用Nokogiri得到以下結果。使用Nokogiri將div嵌套在div元素中
event_name = "folk concert 2"
event_link = "http://www.douban.com/event/12761580/"
event_date = "20th,11,2010"
我知道doc.xpath('//div[@class="nof clearfix"]')
能得到各div
元素,但我應該怎麼着手得到的每個屬性像event_name
,尤其是date
?
HTML
<div class="nof clearfix">
<h2><a href="http://www.douban.com/event/12761580/">folk concert 2</a> <span class="pl2"> </span></h2>
<div class="pl intro">
Date:25th,11,2010<br/>
</div>
</div>
<div class="nof clearfix">
<h2><a href="http://www.douban.com/event/12761581/">folk concert </a> <span class="pl2"> </span></h2>
<div class="pl intro">
Date:10th,11,2010<br/>
</div>
</div>
我完美的作品。謝謝。 – pierrotlefou 2010-11-20 11:46:30