 when I was a kid. I love Snoopy Comics. I used to get the big books from the library and read through them. I just thought they were hilarious and I really just don't find them all that funny anymore. I don't know what I was thinking when I was a kid. But we are going to read a bunch of them and not just read them. We're gonna check them out online and make backup copies for ourselves just so they don't ever disappear. You know, archiving stuff. That's what we do. We're going to use some of the things we've learned in the last two videos with dates to do this. We're going to scrape some websites. Let's check it out. Here we go. There's lots of places where you can read comics legit online. Sunday morning comics, many different ones, but almost all of them are going to have the peanuts because the peanuts are the peanuts. You know, when you think Sunday morning comics, you're probably thinking one of the first ones you think of is the peanuts. We're going to use this website because it's one of the first ones I came to online. It's called gocomics.com. Went there, went to peanuts. Here you can choose a random one. And you can also go to the latest one by clicking this button. Or you can go all the way back to the very first one where they don't even look like the peanuts. October 2nd, 1950. Wow! That was a long time ago. So there's the comic. And of course, like I said, you can click through these and read them for free, which is nice. You can also buy a print of this comic for some reason or you can license this comic. I'm just going to right click. Oh, there's no save image as well. We're smarter than that. We can open up our developers console. Different with each browser. You can hit control shift I or F12. F12 is easier, but some computers nowadays don't have F12 buttons. So I've gotten used to using control shift I. Once that's there, you can make sure you go to the networking panel and then we're just going to look for images. So click on image there. We're going to refresh the page. And here we're going to show you every image that loads on this page. And when we see one that looks like the one we're looking for, that's it right there. We can hover over this and see the name of it. Three ACF ending in C 47. Okay. Let's see how easy this is to grab from our shell. So I'm going to grab the URL up here. I'm going to go to my shell. I'm just going to W get. I'm going to use Q for quiet. Capital O dash. So we just get the code of the page to the shell. And I'm going to pass it that URL, which you can plainly see is just that URL and the date of the comic, which again, previous videos, which just finished rendering as you saw there. We've talked about formatting dates so we can get valid dates for any range we want. We'll go ahead and run that. And of course, we're going to get the HTML for the page. But as we said, we're looking for anything that says three ACF. So I'm going to run that same command, but I'm going to grab for three. What did I say CAF or ACF, ACF? There we go. We've got a few responses. And these all look like the same URL, which is great. This top one here og image is going to be the the fault image that this page will pass to other websites like Facebook that want to post it. So we can look at a few of these different ones and see the quality of them. You might get different qualities from different ones. But let's grab this first one. Let's just go ahead and click on it and open it up. There we go. That looks pretty good to me. So that seems to be the right one. That seems to be the one we want. So we can now get just that. So we've narrowed down our HTML a lot. Just running this one command, you know, getting that one grep command. But now we can just say head dash and one will give us just that first line after we've grabbed. And now we're going to let's see everything's divided by quotation marks. We can go field one, field two, field three, it's going to be field four. So now we can take that same command cut. And if you're new to the shell, this may seem confusing. This kind of an intermediate video. I should have said that at the beginning. But it's very simple. As I said, we are getting the code of the page. We are searching for this. We're grabbing head means start at the top and I'm saying give me just number number lines the first one. Now we're going to say cut. And I'm going to say with a delimiter, which is what we're dividing up by back slash and then we're saying find that line, cut it up by the quotation marks and give me the fourth field. So this would be one. This would be two. This would be three. And this would be four. Doing that will give us the exact URL to the image that we want. Perfect. Okay, now I have this this code from my previous video where we looped through dates, we are going to change that in fact I'm going to move I'm going to rename it to Snoopy. I know it's peanuts, but we're going to call it Snoopy. We're going to go into our Snoopy script. And the first thing I'm going to do is I'm going to create a variable so that if I want to change this for other comics, I can easily change this. Of course, you can get this from user input, but I'm going to grab just the first part of this URL up to here, up to here, there we go. So we're going to use that. Okay, we're going to get a start date, we're going to get an end date from user, we'll print out the out the dates so that we have some sort of output, although W gets going to give us some output as well. We're going to say, double, we're just going to grab this command here. Right, because we know that's going to give us the image we want. I'm going to put this here, but we're going to move forward to the quotation marks here, we're going to delete everything in the quotation marks, and we're going to say dollar sign URL. But not just that URL, we removed the date from it. So now we want format date. And if we look at this again, whoops, we'll go here, we can see it's year month day. So we're going to come up here. And we're going to do this, we're going to do forward slashes instead of dashes. So we're just going to modify our code from the previous video, so that all our dates have forward slashes in them. And that should be it there. Oh, again, down here. There we go. Now, I should be able to say slash dollar sign D. And what that's going to do is it's going to use this URL slash and the date that we're looping through. This will give us for each one of those dates that we're going to loop through the image we want to download. We need we're going to put that into a variable. So we're going to say, I am G for image, we're going to say equals and side quotations, dollar sign and parentheses, we're going to get the URL there. And then we just need to say w get dollar sign, I like to put it in quotation marks, dollar sign image. Now we can give it an output name of the date, or we can just let it name it what the file is. I guess if we want them to be in order, it'd be best if we gave them the date name. But then we're just going to let it download as is. You might want to go a little bit further and actually date them if you care about them being in order. And some of the comics do go in order. So that is important. But just keep the tutorial short. I think I've written everything right. So again, this is going to loop through a range of dates. Now let me open up a file browser so you can see this in action. Okay, so this is the same folder that we're in in the shell here. I should be able to run my script. If I didn't type anything wrong, it's going to ask me for a start date. Our start date is 1950. It's October 2 1950. So again, I can write this in many different ways. I can say I'm just gonna say 10. What do I say the second? Yeah, 02 1950 as a start date. Now I could put a long range of dates. Now, the thing about doing the sort of thing is if you start pulling down a lot, after a while, you're probably going to hit a capture. That's what captures are for. If you were unaware of that, it's to stop people from doing this. If you hit the website a lot, it's going to ask you to prove you're not a robot, which is what this code is. But let's go ahead and just say we're going to go through the end of the year. We'll say 1231 1950. And if I did everything right, it's going to start on that date. And there we go. We have an image. It's going to keep going. Oh, invalid host. What did we do wrong? Let's go ahead and vim our script. And hopefully I'll be able to see what we did wrong here. It's going to be something probably with our date here. Oh, I see, I see. I left the this code. This rep is not going to work. I meant to change that. So if we go back up to our W get command up here, let's go ahead and make this full screen so you can see. We're grabbing for that. And that will return this we don't want that that's going to change every image we want to grab this most likely. So let's go ahead and change that. We're going to say grab the og image. And then we can do our head and one and go from there. So that's why we're getting invalid URLs. So if we go back into our Snoopy script here, now we already downloaded one, which also brings up another subject here. Let's go ahead and change this grep command to be og image. Let's also do dash c for this. That way, if we start a script over or we've already downloaded certain dates, it will continue that download or skip over it if it's already downloaded. Let's go ahead and run that again. Let's go ahead and look at our shell here. We already have one downloaded, but I'm going to clear the screen, run our Snoopy command again. Again, I can say October 2 1950. And I can say 12 31 1950. We're going to go from there also realize that the way we're pulling this down, there are no extensions on these files. They are PNGs. We can double check that. Actually, they're gift files that I'm seeing what W gets doing. And that's again, we're not naming these files. We're using the files, the names that we've downloaded. We again, will probably want to name them if you want them in order and give them proper extensions. Again, Linux is not going to care that there's no extension on their other operating systems might be like, what are these files? Even though a program should not care what the extension is. But as you can see, we're getting plenty of these files. And so far, no capture in sight. But I bet if I did this long enough, I would think that website would start getting errors over here or the files might end up not being images anymore. And that means you'd have to go and prove you're not a robot. But yeah, so that is pulling down a number of comics. We can start looking at these here. Yeah, yeah, yeah, OK. I hope you found this useful. I will put this code up on Pastebin. Check out the links in the description of this video for this code. I hope you learned something new. I hope that you saw at least one way. Being able to format dates a certain way can be very useful, and we will be doing more with dates in the coming videos. Thanks again for watching, and I hope that you have a great day.