Exploring a Page

The important first step in scraping information from a web page is to explore the page, figuring out how to extract information from it, understanding its structure and how to translate our idea of what we want (“the title of the latest post,” “the price of the most expensive product”) into that structure.

It doesn’t make sense to leap straight into writing a script at this point—we’re just exploring, after all. There are two different ways to do this exploration without writing a script, and both are useful. The first is to look at the page in a web browser, using the browser’s inspection tools to explore the structure of the document. The second uses Nokogiri, but from the command line, to bridge the divide between exploring ...

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.