From the course: Build Three Real-World Python Applications

Unlock the full course today

Join today to access over 24,400 courses taught by industry experts.

How to retrieve webpage links

How to retrieve webpage links

- [Instructor] For our last find all statement, we will find all the links on our webpage. Let's start by doing this in this Jupyter Notebook coding cell, and we're going to begin by typing links as our variable and equal it to our variable soup and use the find_all method on it. And we want to find all of the a tags. These a tags will help us gather any URL links in the code. Next, we want to create our for loop. So we'll begin by typing in for, add in our iterator, we'll call it link. We want to look inside our variable links. Make sure you add your colon. Go to the next line and indent in. And now we'll do our print statement to print out the links. So we'll add in print and this print statement will look a little bit different from some of the other ones we did. So first, we're going to add in link.text. Then we'll add a comma, and then we're going to do link.get, and in parentheses, we will put href. What this…

Contents