I am doing HTML cleanup with BeautifulSoup. Noob for Python and BeautifulSoup. I have tags that are deleted correctly, as shown below, based on the answer I found elsewhere in Stackoverflow:
[s.extract() for s in soup('script')]
But how to remove inline styles? For example, the following:
<p class="author" id="author_id" name="author_name" style="color:red;">Text</p> <img class="some_image" href="somewhere.com">
It should become:
<p>Text</p> <img href="somewhere.com">
How to remove the built-in attributes of a class, identifier, name and style for all elements?
Answers to other similar questions. I could find everything mentioned with a CSS parser to deal with this, and not with BeautifulSoup, but since the task is to simply remove and not manipulate attributes, and is a general rule for all tags, I was hoping to find way to do it all in BeautifulSoup.
python css inline beautifulsoup
La
source share