 Welcome back. I'm Dan. I'm Nathan. And we're here on location in San Francisco. It's a beautiful summer day. And we're going to go try to find some iPhones. So last video we left off with a dictionary of Craigslist URLs and Craigslist cities or locations. So each city gave us a URL for that given city. And this video we're going to actually just pick one of those. We're going to start with San Francisco due to the wonderful Bay Bridge behind us. And we're going to see what kind of prices we can find for an iPhone. So let's let's just URL first. Yeah, let's just San Francisco URL equals city dict SF Bay area capital SF capital SF. Thank you, sir. And these are just from our dictionary right above, as you can see. And so stored just perfectly. And then we're going to go back to the requests. So what we're going to do here is just we're going to do another request dot get and add in our URL. But we can't just pass in this URL as is, because as you can see, it's not a complete URL. It needs both a prefix and a suffix to this URL. So we're going to add in the HTTP colon. We don't need the slashes because as you can see, it already has it here. And then we're going to add plus the SF URL plus an appendix. This is just because we're just going to do a search automatically on here to do a search on Craigslist. It has an addition of a search slash SS s. And so then also to get our get, we're going to pass in some variables. To do this, get has another function, takes in another parameter of params. And so we're going to define them first. And it's it's a dictionary that you pass. It's in this particular case, there's quite a few parameters. So I've already written it down here, and I'm just going to come up here and copy and paste it. We'll sort of walk you through each of the the lines in this dictionary. But essentially, what with the sort rel key value pair means that your results are going to be sorted by how relevant they are to your search query. The minimum price means that it's only going to return results that are higher than this. This number you provide, mobile OS, they have a code for iOS. And so the list and number two happens to be for iOS, the query itself, we're going to give it quite a few query terms here, search terms. Firstly, it's going to be iPhone five s. And then we're going to use the Craigslist search syntax, we're going to do a minus cracked minus replacement minus broken minus case minus charger, just to get rid of some of the accessories and repair services and stuff that pop up sometimes in Craigslist results like this. And lastly, we're going to specify search type as as t. So that means it's going to just search the titles only for these query terms that you you provided. Most of these are just to help get rid of different accessories and phone replacements and those kind of things. We're searching titles only because we don't want garage sales and other things like that. Yeah, so just so I'm not sure I specified this, but the minus sign means make sure that the title doesn't have this term that follows the minus sign in the title. So we're going to go ahead and pass the full URL to that and then specify params. And that's going to equal search params. And we're in since we did it before, we could also pass in the headers, which just helps us distinguish what kind of browser we're looking from. Go ahead and hit that. And there we're done. So we've got our response object. And just like last video, we're going to toss this right into a soup object. So we're just I'll just call this s our soup object is s equals beautiful soup. Dot or excuse me, our dot content. And then our parser seems to work just perfectly. And let's take a look at what this looks like. So what about an s dot purify? Because everybody looks like looking at pretty stuff, right? I know, we got to be cheesy all the time. I don't know. I don't know this guy. So there we are. Unlike our previous page, this isn't quite as easy to find what we need in here. So what we used is chrome or Firefox is inspect element. So if we just jump into Craigslist, SF Bay dot Craigslist, we just jump in the Craigslist here, we can right click on an element. Just any which one, and then go inspect element. And we can see at the bottom here what the actual jumps straight to that text and highlights it. And so for this specific one classes, it actually has a class of txt and it's part of a span. Inside of our search results, we found one all the prices were inside of an a link inside of a span with a class. And so what we ended up doing here is we did a find all with an a and with a class of I gallery to pull out the first one. And then we did another find of a span with a class of price. So this is jumping to the first I gallery item, which is all those different big giant cells in Craigslist, and then jumped inside of there just to pull out the price inside of that. Yeah, so the way that what that looks like in practice is for I a in, we're going to use we put I there because we're going to enumerate our s dot find all a tags with the dictionary of class. And what was the I gallery, I space gallery. And so these are all those giant cells for each search result. That would be the I gallery part that came in. And don't forget about your in before the new rate. Oh, thank you, sir. And so from here, we got the whole hyperlink, but that has a text of our pricing. So we're going to pull out that text. And here, we just do price equals a dot find, because we know there's only one of these. We're going to do spam with a class of price. So this will pull up the price tag, but we only want the text the actual price. So we're going to do a dot text at the end of this as well. We'll just append that price to this empty price list that we instantiate at the beginning of this code block. So we'll do price list dot pen price. But just to make this simpler down the road, we're only going to take 20 the first 20 results. So we're going to do an if I this is where our enumerate comes in. If I is less than 20, we're going to do price list dot append for it. Otherwise, we're just going to skip over it. And since we kind of care more about the actual number value, we're going to make this an int as well as taking off the dollar sign. Right. So if I just if I go ahead and just type out the results, or I'll show you what the results were, you can see that these are all strings with the dollar sign in front of them with that dollar sign in the string. But we just value we can't do any crazy math with it like averages. Yes, crazy math. So we'll just we'll turn this into an integer for now. So int take the price to take the dollar sign off. We can start at the first index and go to the end, just because we know the dollar sign is initially the first zero value. And that cuts off that to be able to turn it into an integer simply. Now we have our list of 20 prices. And we took we took the 20 top prices, because if you remember, we searched by relevance. So by searching by relevance, it also helps push all those accessories and repairs and everything to the back of that list of results. That way, hopefully, these 20 results here are purely just iPhones. And as you can see, the prices are fairly consistent. There are a couple outliers, but we'll play around with those numbers down the road. So thanks for joining us. Be sure to join us on our next video when we talk about the Panda's library. See you then. Don't forget to subscribe.