]> git.bitcoin.ninja Git - youtube-dl/commitdiff
ignore parsing errors in get_element_by_id()
authorFilippo Valsorda <filippo.valsorda@gmail.com>
Tue, 10 Apr 2012 21:08:53 +0000 (23:08 +0200)
committerFilippo Valsorda <filippo.valsorda@gmail.com>
Tue, 10 Apr 2012 21:08:53 +0000 (23:08 +0200)
youtube-dl
youtube_dl/__init__.py

index 78fb07ea1b3a69516056831fccdb9b3e31ffc32b..dc7ec136fcbd27957633ccf037bad6e4e136cb43 100755 (executable)
@@ -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()
 
 
index 78fb07ea1b3a69516056831fccdb9b3e31ffc32b..dc7ec136fcbd27957633ccf037bad6e4e136cb43 100755 (executable)
@@ -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()