course content

Course Content

Web Scraping with Python

Working with Specific ElementsWorking with Specific Elements

Navigating an HTML document using Python attributes will return only the first instance of this element. What if you are interested in the first instance of some element but don't know its full path? You can use the .find() method passing the tag (without < > these brackets) as a string. For instance, let's find the first <div> element in the html document.

Also, you can get all the instances of a specific element. You can do it by applying the .find_all() method. As a result, a list of instances will be returned. For example, let's find all the <p> tags in the html document.

You can also use the .find_all() method to find not only one but multiple tags using a list. For instance, let's get all the <div> and <title> elements.

Section 2.

Chapter 5