(page, onlyText=True)
return retVal
Returns filtered page content without script, style and/or comments
    or all HTML tags

    >>> getFilteredPageContent(u'<html><title>foobar</title><body>test</body></html>')
    u'foobar test'
Returns filtered page content without script, style and/or comments
    or all HTML tags
Returns filtered page content without script style and / or comments or all HTML tags
def getFilteredPageContent(page, onlyText=True):
    """
    Returns filtered page content without script, style and/or comments
    or all HTML tags

    >>> getFilteredPageContent(u'<html><title>foobar</title><body>test</body></html>')
    u'foobar test'
    """

    retVal = page

    # only if the page's charset has been successfully identified
    if isinstance(page, unicode):
        retVal = re.sub(r"(?si)<script.+?</script>|<!--.+?-->|<style.+?</style>%s" % (r"|<[^>]+>|\t|\n|\r" if onlyText else ""), " ", page)
        while retVal.find("  ") != -1:
            retVal = retVal.replace("  ", " ")
        retVal = htmlunescape(retVal.strip())

    return retVal
def getFilteredPageContent ( page , onlyText = True ) : retVal = page # only if the page's charset has been successfully identified if isinstance ( page , unicode ) : retVal = re . sub ( r"(?si)<script.+?</script>|<!--.+?-->|<style.+?</style>%s" % ( r"|<[^>]+>|\t|\n|\r" if onlyText else "" ) , " " , page ) while retVal . find ( "  " ) != - 1 : retVal = retVal . replace ( "  " , " " ) retVal = htmlunescape ( retVal . strip ( ) ) return retVal