Skip to content Skip to sidebar Skip to footer

Get Content From Certain Tags With Certain Attributes Using Bs4

I need to get the content from the following tag with these attributes: . An example of the HTML I'll encounter would be Hello

Solution 1:

page = BeautifulSoup(text, 'html.parser')
names = page.find_all('span' , class_ = 'h6 m-0')

Without knowing your use case I don't know if this will work.

Solution 2:

names = [item["class"] for item in page.find_all('span',class_="h6 m-0" )]

can you please be more specific about what problem you face

but this should work fine for you

Post a Comment for "Get Content From Certain Tags With Certain Attributes Using Bs4"