gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 07:28:03 24 4
gpt4 key购买 nike

我在 google 中搜索了一些文本并将页面保存为 html。

但是,当我打开它时,内容就消失了。

这是link我保存的 html。

我可以做什么来恢复内容?

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

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

非常感谢。

最佳答案

您可能想使用BeautifulSoup为了这。操作方法如下:

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

关于python - 如何读取保存的谷歌搜索结果页面?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57352113/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com