1
0
mirror of https://codeberg.org/polarisfm/youtube-dl synced 2024-11-26 10:24:33 +01:00

ignore parsing errors in get_element_by_id()

This commit is contained in:
Filippo Valsorda 2012-04-10 23:08:53 +02:00
parent 781cc523af
commit 7a8501e307
2 changed files with 8 additions and 2 deletions

View File

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

View File

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