Example – Collecting products
In this example, we will use an XPath query to retrieve the latest releases from the Packt Publishing website. On this web page, there are a series of <div> tags that contain more <div> tags, which will eventually lead to our information. Each of these <div> tags hold an attribute called class, which describes what the purpose of the node is. In particular, we are concerned with the landing-page-row class. The book-related <div> tags within the landing-page-row class have an attribute called itemtype, which tells us that the div is for a book and should contain other attributes holding the names and prices. It would not be possible to achieve this with the strings package, and a regular expression would be very ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access