Last week I started to write a script in Ruby. I needed to scrape some data from the web so I was told to use Mechanize and then Nokogiri.
The Mechanize documentation says:
Mechanize uses nokogiri to parse html. What does this mean for you? You can treat a mechanize page like an nokogiri object. After you have used Mechanize to navigate to the page that you need to scrape, then scrape it using nokogiri methods.
I know that I can use xpath
or at_xpath
because it was part of "How do I parse an HTML table with Nokogiri?" but I do not know the exact syntax of these methods, the difference etc.
I was told in "how to use nokogiri methods .xpath & .at_xpath" that
I often use text() expression. This is not required using Nokogiri. You can retrieve the node then call the text method on the node. It's much less expensive.
I tried to search Nokogiri's documentation but didn't find anything on that.
Is out there somebody who can help me read Nokogiri's documentation?
I want to know how to use the text
method instead of text()
.