Вопрос

Using hpricot I can get the content of some divs -

doc = Hpricot(@response)

doc.search(".someDiv").each do |content|
   puts content.inner_html
end

//this puts the following

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

How can I make sure I only put the stuff before the line break?

Это было полезно?

Решение

If the paragraph structure is the same for all divs you could always split the content:

doc = Hpricot(@response)

doc.search(".someDiv").each do |content|
   puts content.inner_html.split("<br>").first
end
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top