Skip to content
Browse files

ignore parsing errors in get_element_by_id()

  • Loading branch information...
1 parent 781cc52 commit 7a8501e307ec1283aeacb03b471b5509b8c92854 @FiloSottile committed Apr 10, 2012
Showing with 8 additions and 2 deletions.
  1. +4 −1 youtube-dl
  2. +4 −1 youtube_dl/__init__.py
View
5 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()
View
5 youtube_dl/__init__.py
@@ -252,7 +252,10 @@ def get_result(self):
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()

0 comments on commit 7a8501e

Please sign in to comment.
Something went wrong with that request. Please try again.