I want to read an HTML file in Python 3.4.3.
I have tried:
import urllib.request
fname = r"C:\Python34\html.htm"
HtmlFile = open(fname,'w')
print (HtmlFile)
This prints:
<_io.TextIOWrapper name='C:\\Python34\\html.htm' mode='w' encoding='cp1252'>
I want to get the HTML source so that I can parse it with beautiful soup.
You will have to read the contents of the file.
HtmlFile = open(fname, 'r', encoding='utf-8')
source_code = HtmlFile.read()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With