Jsoup Get Title From HTML Tutorialspoint Examples
Jsoup Get Title From HTML Tutorialspoint Examples
Tutorialspointexamples
(http://tutorialspointexamples.com)
Learnjavatutorialwithexamplesforbeginnersonline
Search
JsoupGetTitleFromHTMLExample
LetusdiscusshowtogettitlefromHTMLusingJsoupAPIwiththehelpofbelowexample.
Followthebelowsteps:
1.Useconnect(Stringurl)methodofJsoupclasswhichreturnstheconnectionofspecifiedURL.
2.Useget()methodofConnectionclasswhichreturnsDocumentobject.
3.Usetitle()methodofDocumentclasstogetthetitle.
4.Printthetitle.
Example:
JsoupGetTitle.java
http://tutorialspointexamples.com/jsoupgettitlefromhtmlexample/ 1/6
1/20/2016 JsoupgettitlefromHTML|Tutorialspointexamples
importjava.io.IOException;
importorg.jsoup.Jsoup;
importorg.jsoup.nodes.Document;
/**
*ThisclassisusedgettitlefromHTMLusingJsoup.
*@authorjavawithease
*/
publicclassJsoupGetTitle{
publicstaticvoidmain(Stringargs[]){
Documentdocument;
try{
//GetDocumentobjectafterparsingthehtmlfromgivenurl.
document=Jsoup.connect("http://tutorialspointexamples.com/").get();
//Gettitlefromdocumentobject.
Stringtitle=document.title();
//Printtitle.
System.out.println("Title:"+title);
}catch(IOExceptione){
e.printStackTrace();
}
}
}
Output:
Title:Javawithease|Easyandstepbysteplearningofjava.
Downloadthisexample.(http://tutorialspointexamples.com/wp
content/uploads/2015/03/JsoupExample4.rar)
NextTopic:JsoupgetlinksfromHTMLexample.(http://tutorialspointexamples.com/jsoupget
linksfromhtmlexample/)
PreviousTopic:JsoupHTMLparsingfromURLexample.
(http://tutorialspointexamples.com/jsouphtmlparsingfromurlexample/)
RelatedTopics:
Howtobuildjavaprojectusingantineclipse?(http://tutorialspointexamples.com/howtobuildjava
projectusingantineclipse/)
JAXBmarshallingconvertjavaobjecttoxmlexample.(http://tutorialspointexamples.com/jaxb
marshallingconvertjavaobjecttoxmlexampleusingonepojo/)
HowtocreatepdffileinjavausingiTextjar?(http://tutorialspointexamples.com/howtocreatepdffile
injavausingitextjar/)
Genericsclassexample.(http://tutorialspointexamples.com/genericsclassexample/)
OGNLinstruts2.(http://tutorialspointexamples.com/ognlinstruts2/)
HibernateOnetoOneMappingusingxml.(http://tutorialspointexamples.com/hibernateonetoone
mappingusingxml/)
http://tutorialspointexamples.com/jsoupgettitlefromhtmlexample/ 2/6
1/20/2016 JsoupgettitlefromHTML|Tutorialspointexamples
SendinlineimageinemailusingJavaMailAPI.(http://tutorialspointexamples.com/sendinlineimage
inemailusingjavamailapi/)
Quartz2JobListenerexample.(http://tutorialspointexamples.com/quartz2joblistenerexample/)
Jsoup Tutorial
Jsoupoverview.(http://tutorialspointexamples.com/jsoupoverview/)
HTMLparsingfromstring.(http://tutorialspointexamples.com/jsouphtmlparsingfromstringexample/)
HTMLparsingfromfile.(http://tutorialspointexamples.com/jsouphtmlparsingfromfileexample/)
HTMLparsingfromURL.(http://tutorialspointexamples.com/jsouphtmlparsingfromurlexample/)
GettitlefromHTML.(http://tutorialspointexamples.com/jsoupgettitlefromhtmlexample/)
GetlinksfromHTML.(http://tutorialspointexamples.com/jsoupgetlinksfromhtmlexample/)
GetimagesfromHTML.(http://tutorialspointexamples.com/jsoupgetimagesfromhtmlexample/)
GetmetadatafromHTML.(http://tutorialspointexamples.com/jsoupgetmetadatafromhtmlexample/)
Getformparameters.(http://tutorialspointexamples.com/jsoupgetformparametersexample/)
http://tutorialspointexamples.com/jsoupgettitlefromhtmlexample/ 3/6