Python 如何读取保存的谷歌搜索结果页面?

Python 如何读取保存的谷歌搜索结果页面?,python,google-chrome,Python,Google Chrome,我在谷歌搜索了一些文本,并用html保存了页面 然而,当我打开它时,内容消失了 这是我保存的html的最新版本 如何恢复内容 with open('sample.html', 'r') as f: text = f.read() '万象城上海首秀' in text # False, but it should be True 非常感谢。您可能想用它。以下是如何做到这一点: >>> from bs4 import BeautifulSoup as bs >>

我在谷歌搜索了一些文本,并用html保存了页面

然而,当我打开它时,内容消失了

这是我保存的html的最新版本

如何恢复内容

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

'万象城上海首秀' in text # False, but it should be True
非常感谢。

您可能想用它。以下是如何做到这一点:

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

我读了文件,但找不到应该包含的内容。这篇文章可能会有所帮助,