Browse Source

ignore parsing errors in get_element_by_id()

master
Filippo Valsorda 13 years ago
parent
commit
7a8501e307
2 changed files with 8 additions and 2 deletions
  1. 5
      youtube-dl
  2. 5
      youtube_dl/__init__.py

5
youtube-dl

@ -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()

5
youtube_dl/__init__.py

@ -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()

Loading…
Cancel
Save