美丽的汤检查标签中的标签

问题描述 投票:0回答:2
python python-3.x web-scraping beautifulsoup
2个回答
3
投票

也应该可以使用CSS选择器。

http://www.crummy.com/software/BeautifulSoup/bs4/doc/#css-selectors

soup.select("p b")

2
投票
for elem in soup.findAll('p'):
    if elem.findChildren('b'):
        continue #skip the elem with "b", and continue with the loop
    #do stuff with the elem
© www.soinside.com 2019 - 2024. All rights reserved.