Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Attributes & Contents of Multiple Elements | Beautiful Soup: Part II
Web Scraping with Python

Attributes & Contents of Multiple ElementsAttributes & Contents of Multiple Elements

All the methods discussed in the previous chapter can be applied to all elements with a specific tag (i.e., to the result of the .find_all() method). However, it's essential to keep in mind that the outcome of applying the .find_all() method is a list, so you must use attributes and methods for each element individually. Just as we did previously, you should employ a for loop in this context as well. For example, let's retrieve all the attributes of all <div> elements.

The same approach applies to extracting text. For instance, let's obtain all the text from all the <p> elements.

Everything was clear?

Section 3. Chapter 3
course content

Course Content

Web Scraping with Python

Attributes & Contents of Multiple ElementsAttributes & Contents of Multiple Elements

All the methods discussed in the previous chapter can be applied to all elements with a specific tag (i.e., to the result of the .find_all() method). However, it's essential to keep in mind that the outcome of applying the .find_all() method is a list, so you must use attributes and methods for each element individually. Just as we did previously, you should employ a for loop in this context as well. For example, let's retrieve all the attributes of all <div> elements.

The same approach applies to extracting text. For instance, let's obtain all the text from all the <p> elements.

Everything was clear?

Section 3. Chapter 3
some-alt