Thread: keep_only_tags
View Single Post
Old 03-19-2010, 07:29 PM   #4
Starson17
Wizard
Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.
 
Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
Quote:
Originally Posted by ultimatebuster View Post
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.
Starson17 is offline   Reply With Quote