 Hello everybody. In this lesson, we're going to be taking a look at find and find all. Really, we're going to be looking at a ton of different things in this lesson. This is where we really start digging in, seeing how we can extract specific information from our webpage. But in order to do that, let's set everything up where we actually bring in the HTML, like we did in the last lesson. And we're just going to write all this out one more time, just for practice, if nothing else. And then we'll get into actually getting that information from the HTML. So we're going to start by saying from VS for import, beautiful soup. There we go. And import requests. We'll go ahead and run this. Then we're going to come up here, grab our HTML or sorry, our URLs will say URL is equal to, and we'll have that right here. Now we need to say page is equal to no, we'll do requests.get. And then we'll put in our URL right here. And we're going to come over here and run this. And lastly, we need to say soup will say soup is equal to beautiful soup. There we go. And then within our parentheses, we need to specify the page dot text, because we need that. And our parser, which is HTML. And there we go. And let's go ahead and run this. Let's print it out, make sure it's working. And there we go. So we have our soup right here, all this should look really similar to our last lesson. And so now we've brought in our HTML from our page, we have a lot, a lot, a lot of information in here. Now really quickly, let's come over and let's inspect our web page. Now in here, we have a ton of information, right, we have a bunch of different tags and classes and all these other things. But how do we actually use these? Well, that's where the find and find all is going to come into play. And they're pretty similar. And you'll see that in just a little bit. But let's say we want to take one of these tags. And let's come down. Let's say we just want to take this div tag. Now, there's gonna be a lot of different div tags in our HTML. But let's just come right here. Let's go down and let's say, we're gonna call soup, we're gonna say soup, that's all of our information, we're gonna say dot find. Now within our parentheses, we can specify a lot of different things. But we're going to keep it really simple right now, we're just gonna say div. Let's go ahead and run this. What this is going to bring up is the very first div tag in our HTML. And that's gonna be this information right here. Now, let's copy this, I'm gonna do the exact same thing. Except we're gonna say find underscore all. Now let's run this. Now we're gonna have a ton more information. Really all find and find all do is that they find the information now find is only going to find the first response in our HTML. At least that's the div class container. And let's go back up to the top. That's our div class container. But find all is going to find all of them. So it'll put it in this list for you. So it's gonna have this first one. And it goes down to this word slash div, which should be right here. And then we have a comma which separates our next div tag. So that is how we can use it. Now what if we want to specify one of these div tags, we pulled in a ton of them. But we want to just look for one of them. Well, this is something where the class comes in handy, because right now we have classes equal to container classes equal to col md dash 12. I don't know what these are at the off the top of my head. But usually, they'll be somewhat unique. And we can use these to help us specify what we're looking for. For example, just kind of glancing at this, we can also use this a tag if we wanted to look at this. So we could say, oh, we're looking for these hrefs. So we have an href here. And this right down here, we have this href as well. Which again, if you remember from a previous lesson, that stands for a hyperlink. Now something like the class, or the href, or these IDs, these are all attributes. So we can specify or kind of filter down based off of these. Now let's try it. So what we can do is we can do class first. And this is kind of the default within something like find all is you can even do class underscore, we can come right back up, we have this div. And then here's our class. So again, we have to have the div and the class. If we took this a tag, this is an a tag, which would go right here with the class of something like nav link or something like nav link again down here, we need to specify that more. But we have our div. So we'll say cla col md 12, right here. And let's go ahead and run this. And now it's going to pull in just that information. Now we're still getting a list because we have multiple of these. So this div class, col md dash 12 doesn't just happen once if we scroll down, we'll see it multiple times, something like right here. Or actually, let me see right here. So here's this comma, then here's our next one. So we have two of these div tags with a class of col dash md dash 12. And in each of these, we have different information. This looks like a paragraph with this p tag right here. And let's scroll back up. So I also think we should try out doing something like this p tag, typically these p tags stand for paragraphs, or they have the text information in them. Let's try to p tag really quickly. And let's just see what we get. And let's run this. And it looks like we get multiple p tags. Now if we come back here, you can see that there's this information. And it's this information that we're pulling in. And I'm just noticing that from right here. And then we have this information right here. And it looks like there's one more, which is this href, which looks like this open source. So data via, and then that hyperlink or that link right there. So we have three different p tags. Now, just to verify and make sure that that's correct, what we could do is come over here, we're going to click on this paragraph, and it's going to take us to that p tag where the class is equal to lead. Come over here and look at this paragraph. Now we have another p tag right over here, where the class is equal to glif a con glif a con slash education, I have no idea what that means. And then we'll go to our last one, which is right here, where the p tag is equal to we have a tag href class and a bunch of other information. So let's say we just wanted to pull in this paragraph right here. Let's go here and see how we can specify this information. So it looks like p where the class is equal to lead. That looks like it's going to be unique to just that one. So if we come down here, we're going to say comma, and it was class. So you can do a class underscore is equal to, and then we're going to say lead, let's try running this. And we're just pulling in that information. Now let's say we actually want to pull in this paragraph, we actually want this text right here. And this is a very real use case, you know, let's say I'm trying to pull in some information or a paragraph of text. Well, let's copy this. And what we're going to then do is say dot text. And let's run this. Now we're going to get an error right here. And this is a very common error, because we're trying to use find all unfortunately find all does not have a text attribute. We actually need to change this to find. Typically, when I'm working with these find and find alls, I'm using find all most of the time until I want to start extracting text. Then when I specify it, I'll change this back to find just like this. Now let's try this. And now we're getting in parentheses, this information now, this is all wonky and needs to definitely be cleaned up a little bit. But if we go back up, it's no longer in a list. And we no longer have things like these p tags in here, or this class attribute. So we're really just trying to pull out this information. Now, again, this does not look perfect. We can even try to do something like dot strip, look like there's some white space. And that cleans it up a little bit. This definitely looks a little better. And we could definitely go in here and clean this up more. But just for, you know, an example, this is how we can then extract that information. Now let's look at one more example. This is some information. This is what we're going to do kind of our little mini project in the next lesson on. Let's say we wanted to take all this information. Well, what if we wanted to pull in something like the team name, that's going to be in right here in this TR tag. And each of these TR tags have TH tags underneath them. So if we scroll down, you'll notice that each row is this TR tag. So let's go ahead and search for, let's do TH. Let's just search for that first. So let's come right back up here. Let's use this find all. And we'll get rid of this text for right now. And let's just say, we want to look for the TR. Is that what we said we're looking for? No, TH. So let's say we're looking for TH. Let's go ahead and run this. So we're going to have underneath this TH, we have team name, year, wins, losses. And notice these are all the titles. So these titles are the only ones with these TH tags. If we go down, you'll notice that the date is actually TD tags. So now let's go back and look for TD. We'll say D. And this is going to be a lot longer. We have a lot of information, but these are all the rows of data. Let's see if we can just get one piece of this data. We're going to get back, we want just this team name. That's all we're trying to pull in for now. And then we'll try to get this row. And then in the next lesson, we're going to try to get all of this information, make it look really nice. And then we'll put it into a pandas data frame. So let's just get this team name right now. Let's go ahead, we're going to say, TH, let's run this, and we have this TH. And now that we know we're getting this information in, we can do, find, let's run this, there's our team name, I'm just going to say dot text. And again, we can do dot strip, just like that. And bam, we have our team name. So you can kind of start getting the idea of how we're pulling this information out. We're really just specifying exactly what we're seeing in this HTML. And what's really, really helpful. And you know, it's something that I do all the time is I'm inspecting it. I'm just kind of searching like what do I want? What piece of information do I want? Then I go ahead and click on it. And then I'm looking, you know, where is this sitting in the hierarchy? It's within the body. It's within this table with the class of table. Then it's down here where this TR tag and then this TD tag. So I'm looking kind of at the hierarchy. And I'm specifying exactly what I'm looking for. So that is what we're going to look at in today's lesson. That's how we can use find and find all. We were able to look at classes and tags and attributes and variable strings, which is this right here, getting that text and variable strings. And we will look at find and find all and how it's pulling that information in and how we can specify exactly what we're looking for. Now in the next lesson, which is definitely going to be the most exciting one, we're going to try to pull in all of this information. So every single thing, because we'll be able to put all this information into a data frame, which then we can use pandas to really search and manipulate that data within that data frame. So with that being said, that is the end of this lesson. If you liked this video, be sure to like and subscribe. I will see you in the next lesson.