All I want to do is print the HTML text of a simple website put when I try printing, I get the next in raw form with newline characters(\n) instead of new lines. this is my code:
import urllib.request
page = urllib.request.urlopen('http://ift.tt/2dmVUma', data = None)
pageText = page.read()
pageLines = page.readlines()
print(pageLines)
print(pageText)
I've tried all kinds of other stuff and discovered some stuff. When I try to index the pageText variable, even after converting it to a string, it does not find any \n character. If I try copying the raw text myself with the new lines represented as \n and I print() that, it converts the \n characters into actual new lines.
Please help. I am surprised that I found nothing that worked for me. Even on forums, nothing worked.
Aucun commentaire:
Enregistrer un commentaire