例如
bs = BeautifulSoup("<html><a>sometext</a></html>")
print bs.find_all("a",text=re.compile(r"some"))
Run Code Online (Sandbox Code Playgroud)
返回[<a>sometext</a>]
,但当搜索的元素有一个孩子,即img
bs = BeautifulSoup("<html><a>sometext<img /></a></html>")
print bs.find_all("a",text=re.compile(r"some"))
Run Code Online (Sandbox Code Playgroud)
它返回 []
有没有办法用来find_all
匹配后面的例子?