I'm using Beautiful Soup 4 to extract text from HTML files, and using get_text()
I can easily extract just the text, but now I'm attempting to write that text to a plain text file, and when I do, I get the message "416." Here's the code I'm using:
from bs4 import BeautifulSoup
markup = open("example1.html")
soup = BeautifulSoup(markup)
f = open("example.txt", "w")
f.write(soup.get_text())
And the output to the console is 416
but nothing gets written to the text file. Where have I gone wrong?