在 HTML 中同时查找多个 "Text" 选项

Find simultaneous multiple "Text" options in HTML

我正在尝试使用一种简单的语法为标签中的文本查找几个可能的选项。

假设我有以下代码:

multi= soup.find("h3", text="Experience").replace_with(code)

我想找到 text = "Experience""Summary"

我试过了:

multi= soup.find("h3", {text:["Experience",'Summary']}).replace_with(code)

但是没用。

您可以使用正则表达式

import re
soup.find(text=re.compile('Experience|Summary')).replace_with(code)