Strip text except from the contents of a tag

Posted by myle on Stack Overflow See other posts from Stack Overflow or by myle
Published on 2010-06-13T14:22:42Z Indexed on 2010/06/13 14:32 UTC
Read the original article Hit count: 215

Filed under:
|
|

The opposite may be achieved using pyparsing as follows:

from pyparsing import Suppress, replaceWith, makeHTMLTags, SkipTo
#...
removeText = replaceWith("")
scriptOpen, scriptClose = makeHTMLTags("script")
scriptBody = scriptOpen + SkipTo(scriptClose) + scriptClose
scriptBody.setParseAction(removeText)
data = (scriptBody).transformString(data)

How could I keep the contents of the tag "table"?

© Stack Overflow or respective owner

Related posts about python

Related posts about parsing