문제

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