Re: [Htmlparser-user] why the propram stop sometimes?
Brought to you by:
derrickoswald
|
From: JeffJie <Je...@bo...> - 2005-12-09 04:57:27
|
thank you.I have add the code to my main program.it seems work.but in fact the code doesn't work for the right place. another block of my code: Page page = new Page(manager.openConnection(url)); page.setEncoding(Global.PAGE_ENCODING); ps = new Parser(new Lexer(page)); after adding the timeout,when connection timeout occur.a ParserException was throwed : Exception getting input stream from http://localhost:8081/test/count then look back the code last time I paste here: fb.setParser(ps); the program still stop here sometimes.seems the time out doesn't work. could you please help me find out the answer.thank you! ---------- Original Message ---------------------------------- From: Derrick Oswald <Der...@Ro...> Reply-To: htm...@li... Date: Tue, 20 Sep 2005 07:39:56 -0400 >It's probably not timing out on the fetch from the page. >Try adding this to your main program: > > System.setProperty ("sun.net.client.defaultReadTimeout", "7000"); > System.setProperty ("sun.net.client.defaultConnectTimeout", "7000"); > > >JeffJie wrote: > >>hello. I got a problem when working with htmlparser. >>my program sometimes stop when invoking the api of the htmlparser. >>I wrote the function want to get the content in the specific tag,the tag has one attribute and has it's own value. >>here's part of my code: >>----------------------------------------------------------------------------- >>private NodeList filterResult(Parser ps, String key_name, String attr_name, String attr_value) { >> >> NodeFilter name=new TagNameFilter(key_name); >> >> NodeFilter attr=new HasAttributeFilter(attr_name,attr_value); >> >> NodeFilter tag=new AndFilter(name,attr); >> >> NodeFilter[] nf=new NodeFilter[1]; >> >> nf[0]=tag; >> FilterBean fb=new FilterBean(); >> >> fb.setFilters(nf); >> if(log.isInfoEnabled()){ >> log.info("now setting the parser"); >> } >> fb.setParser(ps); //program stop here >> if(log.isInfoEnabled()){ >> log.info("finished form the filter"); >> } >> return fb.getNodes(); >>} >>--------------------------------------------------------------------------- >>the argument "ps" had been initail like this: >>--------------------------------------------------------------------------- >> String url = "http://foo.bar.com"; >> ConnectionManager manager = new ConnectionManager(); >> Page page = new Page(manager.openConnection(url)); >> page.setEncoding(Global.PAGE_ENCODING); >> >> Parser ps = new Parser(new Lexer(page)); >>----------------------------------------------------------------------------- >>problem comes up at the mark line.the code is: >>fb.setParser(ps); >>where the program run,the log before this line execute normally.but the log after the line sometimes never execute. >>does it has the matter with the firewall?or any other reason? I need your help!thanks. >> >> >> >> >>________________________________________________________________ >>Sent via the WebMail system at botwave.com >> >> >> >> >> >> >>------------------------------------------------------- >>SF.Net email is sponsored by: >>Tame your development challenges with Apache's Geronimo App Server. Download >>it for free - -and be entered to win a 42" plasma tv or your very own >>Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php >>_______________________________________________ >>Htmlparser-user mailing list >>Htm...@li... >>https://lists.sourceforge.net/lists/listinfo/htmlparser-user >> >> >> > > > >------------------------------------------------------- >SF.Net email is sponsored by: >Tame your development challenges with Apache's Geronimo App Server. Download >it for free - -and be entered to win a 42" plasma tv or your very own >Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php >_______________________________________________ >Htmlparser-user mailing list >Htm...@li... >https://lists.sourceforge.net/lists/listinfo/htmlparser-user > ________________________________________________________________ Sent via the WebMail system at botwave.com |