BeautifulSoup: append() Example
Syntax
append("Your_text")
append() Example
from bs4 import BeautifulSoup
# Html source
html_source = '''
<div>
<h1>home 1</h1>
</div>
'''
# Parsing
soup = BeautifulSoup(html_source, 'html.parser')
# Get <h1> tag
el = soup.h1
# Append to tag value
el.append(" Text")
# Print
print(el)
Output:
<h1>home 1 Text</h1>