ignore parsing errors in get_element_by_id()

pull/329/head
Filippo Valsorda 2012-04-10 23:08:53 +02:00
rodzic 781cc523af
commit 7a8501e307
2 zmienionych plików z 8 dodań i 2 usunięć

Wyświetl plik

@ -252,7 +252,10 @@ class IDParser(HTMLParser.HTMLParser):
def get_element_by_id(id, html):
"""Return the content of the tag with the specified id in the passed HTML document"""
parser = IDParser(id)
parser.loads(html)
try:
parser.loads(html)
except HTMLParser.HTMLParseError:
pass
return parser.get_result()

Wyświetl plik

@ -252,7 +252,10 @@ class IDParser(HTMLParser.HTMLParser):
def get_element_by_id(id, html):
"""Return the content of the tag with the specified id in the passed HTML document"""
parser = IDParser(id)
parser.loads(html)
try:
parser.loads(html)
except HTMLParser.HTMLParseError:
pass
return parser.get_result()