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 - Python Tutorial
From the course: Build Three Real-World Python Applications
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
-
-
-
What is web scraping?2m 57s
-
Introducing the Wisdom Pet Medicine website2m 4s
-
How to explore a webpage2m 45s
-
(Locked)
Understanding HTML code1m 56s
-
(Locked)
Understanding the requests package3m 8s
-
(Locked)
How to use the get() method2m 38s
-
(Locked)
How to retrieve webpage information4m 4s
-
(Locked)
How to retrieve HTML code1m 36s
-
(Locked)
How to use BeautifulSoup2m 20s
-
(Locked)
How to use find() and find_all() methods3m 52s
-
(Locked)
How to loop find_all() methods3m 21s
-
(Locked)
How to retrieve webpage links2m 18s
-
(Locked)
How to write HTML code to a text file2m 7s
-
-
-
-