0

Tag on google page- <title>Google</title> I am trying to retrieve text content in title tag.But i am not getting an output.It shows Build Successfull and throws output as "TITLE".I need a output as "GOOGLE". Here is my code.

import org.htmlparser.Node;
import org.htmlparser.Parser;
import org.htmlparser.filters.HasAttributeFilter;
import org.htmlparser.filters.IsEqualFilter;
import org.htmlparser.tags.MetaTag;
import org.htmlparser.tags.TitleTag;
import org.htmlparser.util.NodeList;
import org.htmlparser.util.ParserException;
public class abc {
public static void main(String[] args) {
       Parser parser=new Parser();


       try
       {
           parser.setResource("http://www.google.com");
          TitleTag title=new TitleTag();
          String tagtext=title.getTitle();
          System.out.println(tagtext);


       }

       }catch (ParserException e) {

        }

    }
}
Anish
  • 1
  • 3

1 Answers1

0

In the code that you have posted there is no connection between the parser and the TitleTag.

The idea is to iterate through a list of nodes (including TitleTag nodes) that the parser has.

See java - org.htmlparser.Parser , need to get whats between the h3's

Community
  • 1
  • 1
Scary Wombat
  • 44,617
  • 6
  • 35
  • 64