This is how it is done when attribute value we are looking for is known:
from bs4 import BeautifulStoneSoup
soup = BeautifulStoneSoup(html, 'html.parser')
found_elems = soup.find_all(attrs={"myattribute" : "myknownvalue"})
How do I find all elements with "myattribute" attribute, not knowing it's value?
If you don't know value of attribute, set it to True
:
from bs4 import BeautifulStoneSoup
soup = BeautifulStoneSoup(html, 'html.parser')
found_elems = soup.find_all(attrs={"myattribute": True})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With