def parse_title(markup, charset=None): parser = TitleParser() try: title = parser.parse(markup) converted, original_encoding = unicodify(markup, [charset] or []) return converted except: return ''
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 ''