I\'m trying to get the content of the particular tag which having the attribute but no values. How can I get it for example
cont = \' <
You can use attr=True for this case.
attr=True
cont = ' aa ' soup = BeautifulSoup(cont, 'lxml') # works with 'html.parser' too. print(soup.find('nav', breadcrumbs=True)) # which is the same as print(soup.find('nav', {'breadcrumbs': True}))
Output:
aa