期望值:
>>> s = BeautifulSoup('<a href="http://example.com">lele</a>')
>>> s.find('a', text='lele')
<a href="http://lele.com">lele</a>
意外:
>>> s = BeautifulSoup('<a href="http://example.com">lele<i><i></a>')
>>> s.find('a', text='lele') # return None
>>> s.find('a', text=re.compile('lele')) # return None
因此,在意外的情况下,a标记中的i标记似乎会通过文本破坏搜索功能,即使使用regex也是如此。有没有一种方法可以让文本搜索在意外情况下工作
目前没有回答
相关问题 更多 >
编程相关推荐