From: Filippo Valsorda Date: Tue, 10 Apr 2012 21:08:53 +0000 (+0200) Subject: ignore parsing errors in get_element_by_id() X-Git-Url: https://git.cielonegro.org/gitweb.cgi?a=commitdiff_plain;h=7a8501e307ec1283aeacb03b471b5509b8c92854;p=youtube-dl.git ignore parsing errors in get_element_by_id() --- diff --git a/youtube-dl b/youtube-dl index 78fb07ea1..dc7ec136f 100755 --- a/youtube-dl +++ b/youtube-dl @@ -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() diff --git a/youtube_dl/__init__.py b/youtube_dl/__init__.py index 78fb07ea1..dc7ec136f 100755 --- a/youtube_dl/__init__.py +++ b/youtube_dl/__init__.py @@ -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()