Issue
Here is my code:
<h1 onclick="alert('Hello')">Click</h1>
I want to do this:
<h1>Click</h1>
Solution
Solution:
from bs4 import BeautifulSoup
html = """<h1 onclick="alert('Hello')">Click</h1>"""
a = BeautifulSoup(html,'html.parser')
for tag in a.find_all():
if 'onclick' in tag.attrs:
tag.attrs.pop('onclick')
print(a)
#<h1>Click</h1>
Answered By - LatestW
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.