From the course: Using Python for Automation (2019)

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

How to isolate data

How to isolate data

- [Instructor] When it comes to your HTML document, there's a lot of information, and it may seem like we have to write a lot of code to grab the data we want, but actually, Beautiful Soup makes it possible to do this in a single line of code. In our example, by searching for all of the elements with the span tag in the class text, we're able to obtain just the quote information. The function we'll use is the find_all function which hones in on the tag and class we specify. Quotes now contains a list of all the elements on the HTML website with the tag, span and the class, text. Let's go ahead and print this variable. As you can see, we have the text property for each element, but also some extra HTML information. From here, let's try removing the HTML. We do that by just printing the text property. I'll go ahead and create a loop to print each quote. Great, as you can see, we've successfully scraped every quote from the website. But we want more than just the…

Contents