简体   繁体   中英

Beautiful Soup 4 parsing

How can i find all divs that have more than one parameters like this this is under a td tag

<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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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