BeautifulSoup Find H1 Tag Example

Syntax

soup.h1

Find H1 Example

from bs4 import BeautifulSoup # 👉️ Import BeautifulSoup module

# 👇 HTML Source
hrml_source = '''
<h1>Hello BeautifulSoup</h1>
'''

soup = BeautifulSoup(hrml_source, 'html.parser') # 👉️ Parsing

print(soup.h1)

Output:

<h1>Hello BeautifulSoup</h1>