Learn Before
BeautifulSoup Tag attributes
BeautifulSoup Tag: attrs
The attrs attribute of Tag returns a dictionary of attribute-value pairs of the tag.
from bs4 import BeautifulSoup soup = BeautifulSoup('<ex class="example">\ This is an example</ex>', 'html.parser') tag = soup.ex # <ex class='example'>This is an example</ex> tag.attrs # {'class': ['example']}
0
1
4 years ago
Tags
Python Programming Language
Data Science
Related
BeautifulSoup Tag: name
BeautifulSoup Tag: attrs
BeautifulSoup Tag: text
BeautifulSoup Tag: next_sibling
BeautifulSoup Tag: previous_sibling
BeautifulSoup Tag: contents
BeautifulSoup Tag: parent