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
  • 2,855
  • 6
  • 27
  • 50

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
>>> 
Black Thunder
  • 6,215
  • 5
  • 27
  • 56