[Htmlparser-developer] Simple extarcting of data from html-file
Brought to you by:
derrickoswald
|
From: Kaarle K. <kaa...@ik...> - 2001-10-13 18:17:18
|
Hi!
I have added the parseParameters method to
parse the parameters of the tag.
parseParameters does not function yet if some of the
listener classes have been registered but without
any listeners you can extract data you need from your html file.
This example is also in the class comments.
It parses all HREF parameters from all A tag's.
I use it myself for some more special extracts.
This version of HTMLTag.java you can find in the CVS-repository.
regards
Kaarle Kaila
HTMLTag tag;
Hashtable h;
String tmp;
try {
HTMLReader in = new HTMLReader(new FileReader(path),2048);
HTMLParser p = new HTMLParser(in);
Enumeration en = p.elements();
while (en.hasMoreElements()) {
try {
tag = (HTMLTag)en.nextElement();
h = tag.parseParameters();
tmp = (String)h.get(tag.TAGNAME);
if (tmp != null && tmp.equalsIgnoreCase("A")) {;
System.out.println("URL is :" + h.get("HREF"));
}
} catch (ClassCastException ce){}
}
}
catch (IOException ie) {
ie.printStackTrace();
}
---------------------------------------------
Kaarle Kaila
http://www.iki.fi/kaila
mailto:kaa...@ik...
|