Esempio n. 1
0
def parse_title(markup, charset=None):
    parser = TitleParser()
    try:
        title = parser.parse(markup)
        converted, original_encoding = unicodify(markup, [charset] or [])
        return converted
    except:
        return ''
Esempio n. 2
0
def parse_excerpt(markup, target_url, max_words, charset=None):
    parser = ContextualExcerptParser()
    try:
        found_excerpts = parser.parse(markup, max_words)
    except:
        return ''
    if found_excerpts:
         excerpt = found_excerpts[0]
         converted, original_encoding = unicodify(excerpt, [charset] or [])
         return converted
    return ''