def extractFromHTML(html, blur=5):
    """
    Extracts text from HTML content.
    """

    #html = html.encode('utf-8', errors='ignore')
    try:
        html = unicode(html, errors='ignore')
    except TypeError:
        pass
    assert isinstance(html, unicode)

    # Create memory file.
    _file = StringIO()

    # Convert html to text.
    f = formatter.AbstractFormatter(formatter.DumbWriter(_file))
    p = TextExtractor()
    p.pathBlur = blur
    p.feed(html)
    p.close()
    text = p.get_plaintext()

    # Remove stand-alone punctuation.
    text = re.sub("\s[\(\),;\.\?\!](?=\s)", " ", text).strip()

    # Compress whitespace.
    text = re.sub("[\n\s]+", " ", text).strip()

    # Remove consequetive dashes.
    text = re.sub("\-{2,}", "", text).strip()

    # Remove consequetive periods.
    text = re.sub("\.{2,}", "", text).strip()

    return text
Extracts text from HTML content.