BeautifulSoup: soup.name Example
Syntax
el.name
Example
from bs4 import BeautifulSoup
html = """
<h2>Syntax</h2>
"""
soup = BeautifulSoup(html, 'html.parser')
# Get H2 Element
el = soup.h2
# Print name of element
print(el.name)
Output:
h2