hi, how to get web page title for given url using html parser. It is possible to get using regular expression,But I want to get that using html parser. I'm working on elipse IDE in java environment. I have tried out using following code segment .But still couldn't get the result.
Any idea..?
Thank in advance!
import org.htmlparser.Node;
import org.htmlparser.Parser;
import org.htmlparser.util.NodeList;
import org.htmlparser.util.ParserException;
import org.htmlparser.tags.TitleTag;
public class TestHtml {
public static void main(String... args) {
Parser parser = new Parser();
try {
parser.setResource("http://www.yahoo.com/");
NodeList list = parser.parse(null);
Node node = list.elementAt(0);
if (node instanceof TitleTag) {
TitleTag title = (TitleTag) node;
System.out.println(title.getText());
}
} catch (ParserException e) {
e.printStackTrace();
}
}
}