Code

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

Updated 2021-02-08

Contributors are:

Who are from:

Tags

Python Programming Language

Data Science