Alex Zakruzhetskyi Alex Zakruzhetskyi - 17 days ago 8
Ruby Question

Is it possible not to get two last elements via nokogiri?

I want to take all

<p>
elements, using this code:

novelty.body = page.css('.rt-article p').text


but I don't want to get last two
<p>
elements. Is it possible to do?

Answer

Yes,

page.css('.rt-article p').text.slice(0...-2)

Notice, there are three dots.

Comments