From the course: Build Three Real-World Python Applications
Unlock this course with a free trial
Join today to access over 25,500 courses taught by industry experts.
How to write HTML code to a text file - Python Tutorial
From the course: Build Three Real-World Python Applications
How to write HTML code to a text file
- [Instructor] To wrap up this chapter we will export our scraped HTML code into a text file. There are multiple ways to do this but we will show the following way of how to send information to a text file. We begin by opening our text file by typing in with and open. And then we need to name our text file. I'm going to name my text file Wisdom vet.txt but you are welcome to name your file something else. Just make sure you have the .txt at the end of it. Then we add a comma and we add the letter W and that shows that we want to write something to this file. If we get out of these parentheses, we will type in as f and this will allow us to name our new file function F. We'll go to the next line. Make sure you indent in. We're going to type in our variable F and a period and then we want to do our write function and we are going to write our soup.prettify and add parentheses. So this will write our soup variable in…
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
-
-
-
-