2012-06-20 21 views
0

從DIV內容使用角度來說,Hpricot我可以得到一些div的內容 -取得突破之前

//這使以下

cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non 
proident, sunt in culpa qui officia deserunt mollit anim id est laborum. 
<br> 
some more text, images and other stuff 

我怎樣才能確保我只放了東西在換行之前?

回答

1

如果段落結構是所有div你總是可以分裂內容相同:

doc = Hpricot(@response) 

doc.search(".someDiv").each do |content| 
    puts content.inner_html.split("<br>").first 
end 
+0

完美,感謝v多少 – Finnnn