Quote:
Originally Posted by ultimatebuster
So apparently you can keep the tag with a the id of "content"
Code:
keep_only_tags = [dict(id=['content'])]
However, is it possible to keep the tag with a class? As the class is a built-in word for python, like:
Code:
<div class="content" id="124"></div>
|
The tags are all processed by BeautifulSoup, and
here is a link explaining the interaction between the Python keyword and BeautifulSoup.
In short, the answer is that you can keep or remove tags with the "class" keyword without conflict with the Python keyword. Almost all recipes do, and looking at a few will show you how it's done.