Wrapping Up

This chapter had a lot to take in. You learned the basics of Nokogiri and how you can use both CSS and XPath queries to search for elements within the document. We looked at what we can do with elements once we got a hold of them, accessing their attributes and their inner text. But we also learned some principles about what makes a good selector and what we should be looking for when we’re exploring a page.

Finally, though, we saw how to translate this all into the real world, writing a robust script that queries information from a web page and translates it into a Ruby data structure. This illustrates how powerful scraping can be. The information we wanted wasn’t intended for machine consumption at all. No API existed, but we were ...

Get Text Processing with Ruby now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.