简体   繁体   English

美丽汤4解析

[英]Beautiful Soup 4 parsing

How can i find all divs that have more than one parameters like this this is under a td tag 我如何找到所有具有多个这样的参数的div,这在td标签下

<td id = "abcdef">
    <div class="12345" id="456" abc="789" def="1123" ghi="">

i tried 我试过了

soup.find_all("div",{"class":"12345"})

and

soup.find_all("div",class_="12345")

both statements return empty. 这两个语句都返回空。

it doesn't matter what the other elements are i just want to compare for class parameter. 我只想比较参数的其他元素没关系。

You can try the following : 您可以尝试以下方法:

soup = BeautifulSoup(html_doc, 'html.parser')
td = soup.find('td')
td.find_all('div', attrs={"class": "12345"})

Hope it helps 希望能帮助到你

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM