Sunday, 10 April 2016

Python - How to read HTML line by line

I am trying to write a program that will take an HTML file and output each line. I am doing something wrong because my code is outputting each letter. How can I get all the HTML lines into a list?



This is the code so far:



f = open("/home/tony/Downloads/page1/test.html", "r")
htmltext = f.read()
f.close()

for t in htmltext:
print t + "\n"

No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...