Skip to content

Instantly share code, notes, and snippets.

@myfreax
Last active October 26, 2019 08:05
Show Gist options
  • Save myfreax/f260cbb298582637e5e3e7ead609eb54 to your computer and use it in GitHub Desktop.
Save myfreax/f260cbb298582637e5e3e7ead609eb54 to your computer and use it in GitHub Desktop.
BeautifulSoup remove html element attrs
from bs4 import BeautifulSoup
with open("mock/scrapy-post.html") as fp:
sp = BeautifulSoup(fp,features="lxml")
childs = sp.find('body').children
for element in childs:
element.attrs = {}
print(element)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment