Parsing the DOM to extract pricing data

The DOM is the collection of elements that form the structure a web page. If you have ever viewed the source of a web page, you have seen the components of the DOM. They include elements and tags such as body, div, class, and id. We'll need to work with these elements to extract the data we need.

Let's take a look at the DOM for our Google page. To see it, right-click on the page and click on Inspect element. This should be the same for Firefox or Chrome. This will open the developer tab that allows you to see the page source information. Once this is open, choose the element selector in the upper left corner, and click on one of the price bars to jump to that element.

Image from ...

Get Python Machine Learning Blueprints now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.