Re: [Htmlparser-user] extract links
Brought to you by:
derrickoswald
From: Somik R. <so...@ya...> - 2002-04-08 04:22:15
|
Mats wrote : > So can i not some how get the htmlparser (just the extract link programs) to work with my WebPage Viewer so that i enter a > search like before but this time the HTML page shown in my window is just the extracted links? Can I do this? If so how? Yes you can do this. Look at the program MailRipper.java in the com.kizna.html.parserapplications package. This program will print only the email addresses on a page (which are also link tags). Its even simpler to simply filter out all the tags except the link tags. Try this : HTMLParser parser = new HTMLParser("http://myurl.com"); HTMLNode node; for (Enumeration e = parser.elements();e.hasMoreElements();) { node = (HTMLNode)e.nextElement(); // Get the next html node if (node instanceof HTMLLinkTag) { // Yes - this is a web link. Now you can downcast and do what you want with it HTMLLinkTag linkTag = (HTMLLinkTag)node; System.out.println("link to "+linkTag.getLink()+", link text = "+linkTag.getLinkText()); } } This should give you what you want. Regards, Somik _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com |