Re: [Htmlparser-user] How to use it.
Brought to you by:
derrickoswald
From: Somik R. <so...@ya...> - 2002-11-25 19:51:14
|
Hi Navid, I ran the program, and it does exactly what I expected. But I see your doubt now. You want to suppress the exception messages. These are happening because of DefaultHMLParserFeedback(). Pls write your own NullHTMLParserFeedback(), that does not print anything when it encounters an error, and use that to initialize the parser. Read the javadoc of HTMLParser.java carefully. I have written the modified program for you : public void testNullUrl(){ try { parser = new HTMLParser("http://www.yahooeeeeee.com",new HTMLParserFeedback() { /** * @see org.htmlparser.util.HTMLParserFeedback#info(String) */ public void info(String message) { } /** * @see org.htmlparser.util.HTMLParserFeedback#warning(String) */ public void warning(String message) { } /** * @see org.htmlparser.util.HTMLParserFeedback#error(String, HTMLParserException) */ public void error(String message, HTMLParserException e) { } }); //assertTrue("Should have thrown an exception!",false); parser.registerScanners(); parser.addScanner(new HTMLLinkScanner("-l")); } catch (HTMLParserException e) { System.out.println("Can not connect the URL!"); } } Try this- it should give you what you want now. Regards Somik (The earlier mail went before I could complete it..) __________________________________________________ Do you Yahoo!? Yahoo! Mail Plus Powerful. Affordable. Sign up now. http://mailplus.yahoo.com |