Results 1 to 1 of 1
- 12-13-2010, 01:37 PM #1
Member
- Join Date
- Mar 2010
- Posts
- 10
- Rep Power
- 0
how to get the right node from web with html parser
Hello all!
I want to get all nodes the have :
<div class="user-thread">
of others,the structure is
I use the org.htmlparser.Parser;Java Code:<div class="user-thread"> <ul class="uinfo2"><li class="uname2"><b>Farzam</b></li> <li class="ureport"><span title="Report inappropriate content"><a href="#" onClick="ReportW('1998748');return false">Report</a></span></li></ul> <p class="uopin"> <span class="uinreply" title="Dear All, can anyone tell me the best jailbreak for my iphone 4.2.1? many thanks">> In reply to amir @ 2010-12-12 13:18 from 3ZIs</span>salam dada khubi bebin jailbreak kolan ta jay ke man midunam ba cidya injam mishe vali agar kam jilbreak nakoni ke khube??? man hamin jurish kheili raziam:D</p> <ul class="uinfo"> <li class="ureply"><span title="Reply to this post"><a href="postopinion.php3?idPhone=3275&idOpinion=1998748">Reply</a></span></li> <li class="upost">2010-12-13 13:52</li> <li class="ulocation"> <span title="Encoded location">Sc{a</span></li> <li class="utype"><span title="Type: Reply to post / answer to question"> R</span> </li> </ul> </div>
But I just dont know how to get specific nodes with that class name,
my code is:
can you help me? thanks a lot.Java Code:public void extractNode(String url) throws ParserException{ Parser parser = new Parser(); //<meta name="description" content="Some texte about the site." /> HasAttributeFilter filter = new HasAttributeFilter("class", "user-thread"); try { parser.setResource(url); NodeList list = parser.parse(filter); Node node = list.elementAt(0); System.out.println(node); // Prints: "YouTube is a place to discover, watch, upload and share videos." } catch (ParserException e) { e.printStackTrace(); } }Last edited by vitaly87; 12-13-2010 at 02:51 PM.
Similar Threads
-
HTML parser
By Yuuki in forum New To JavaReplies: 4Last Post: 10-25-2010, 11:32 AM -
problems with html parser
By vitaly87 in forum Advanced JavaReplies: 0Last Post: 03-13-2010, 01:37 PM -
Problem with HTML parser
By kpraveenreddy in forum New To JavaReplies: 0Last Post: 03-02-2010, 02:12 PM -
Jericho HTML Parser 2.6
By Java Tip in forum Java SoftwareReplies: 0Last Post: 06-26-2008, 06:22 PM -
Jericho HTML Parser 2.4
By levent in forum Java SoftwareReplies: 0Last Post: 05-21-2007, 10:05 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks