1

I search some text in google and saved the page in html.

However, when I opened it, the content disappeared.

Here is the link of my saved html.

What can I do to restore the content?

with open('sample.html', 'r') as f:
    text = f.read()

'万象城上海首秀' in text # False, but it should be True

Thank you very much.

Chan
  • 3,605
  • 9
  • 29
  • 60

1 Answers1

1

You might want to use BeautifulSoup for this. Here is how to do it:

>>> from bs4 import BeautifulSoup as bs
>>> soup = bs(open("file.html","r").read(), "html.parser")
>>> '万象城上海首秀' in soup.text
True
>>> 
Nouman
  • 6,947
  • 7
  • 32
  • 60