Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
79 views

Jsoup Get Title From HTML Tutorialspoint Examples

1. The document discusses how to get the title from HTML using the Jsoup API. 2. It provides steps to connect to a URL, get the document object, and use the title() method to retrieve the title. 3. The code example connects to a URL, gets the title, and prints it out, outputting "Javawithease | Easy and step by step learning of java."

Uploaded by

Rahmad Afandi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
79 views

Jsoup Get Title From HTML Tutorialspoint Examples

1. The document discusses how to get the title from HTML using the Jsoup API. 2. It provides steps to connect to a URL, get the document object, and use the title() method to retrieve the title. 3. The code example connects to a URL, gets the title, and prints it out, outputting "Javawithease | Easy and step by step learning of java."

Uploaded by

Rahmad Afandi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

1/20/2016 JsoupgettitlefromHTML|Tutorialspointexamples

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/)

9 0 Share 7 Share 0 0 Share 0 0


0 Share 0 0

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

You might also like