Saturday, 15 February 2014

java - Extracting links from all heading tags using jSoup -


I get all the title tags & lt; H3 & gt; Trying to remove the link (title and its address) from exists in the web page.

I have tried which code is:

  string U = "http://www.thehindu.com/business/"; Document document = (document) Jsoup.connect (U) .get (); Element lnk = docu.select ("h3"); For (Element A: LNK) {String S = A.T.T.R. ("abs: href"); String name = an.text (); System.out.println (s); }  

I do not find any output What is the problem?

You selected h3 and you are trying to read its href is attribute, but is not near h3 (no

). The one you want to select is a which is placed inside the h3 and reads it as href .

Then your code should look more

  string Y = "http://www.thehindu.com/business/"; Document document = (document) Jsoup.connect (U) .get (); Elements lnk = docu.select ("h3 a [href]"); For (Element A: LNK) {String S = A.T.T.R. ("abs: href"); String name = an.text (); Println (name); Println (s); Println ("--------"); }  


No comments:

Post a Comment