Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
同じコンテンツの html ページを解析するために Nokogiri を使用します。
<p class="parent"> Useful text <br> <span class="child">Useless text</span> </p>
メソッドpage.css('p.parent').textNokogiri を呼び出すと、「有用なテキスト 役に立たないテキスト」が返されます。しかし、「役立つテキスト」だけが必要です。
page.css('p.parent').text
子なしでノードテキストを取得するには?