diff options
Diffstat (limited to 'bs4/diagnose.py')
-rw-r--r-- | bs4/diagnose.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/bs4/diagnose.py b/bs4/diagnose.py index 5192a3f..daaf523 100644 --- a/bs4/diagnose.py +++ b/bs4/diagnose.py @@ -24,13 +24,17 @@ def diagnose(data): for parser in basic_parsers: print "Trying to parse your data with %s" % parser + success = False try: soup = BeautifulSoup(data, parser) - print "Here's what %s did with the document:" % parser - print soup.prettify() + success = True except Exception, e: print "%s could not parse the document." % parser traceback.print_exc() + if success: + print "Here's what %s did with the document:" % parser + print soup.prettify() + print "-" * 80 def lxml_trace(data, html=True): |