Alex Zakruzhetskyi Alex Zakruzhetskyi - 1 year ago 65
Ruby Question

Get <a> content via Nokogiri

I'm trying to get a content of

element via
by doing the following:

novelty.title = page.at_css('h1 a')

It saving to database like this:
<a href="a_link_to_a_novelty_title">A title</a>
. So, how can I get only
A title
from the
tag? Thanks.

Answer Source

You can write as below to get the text.

ovelty.title = page.at_css('h1 a').text
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download