there maybe more then 1 link in this html i want them extracted just as i have extracted othe info , am just stuck at extracting the ( ahref ) link from listing-link tag
protected Void doInBackground(Void... params) {
// Create an array
arraylist = new ArrayList<HashMap<String, String>>();
try {
// Connect to the Website URL
Document doc = Jsoup.connect(url).get();
// Identify Table Class "worldpopulation"
Elements hrefElements = doc.select("div.listing-content");
Elements links = doc.select("a[href]");
for (Element table : doc.select("div[class=listing-content]")) {
// Identify all the table row's(tr)
for (Element row : table.select("div:gt(0)")) {
HashMap<String, String> map = new HashMap<String, String>();
String[] titlee = new String[hrefElements.size()];
String[] description = new String[hrefElements.size()];
String[] distance = new String[hrefElements.size()];
String[] posted = new String[hrefElements.size()];
String[] pricee = new String[hrefElements.size()];
String[] imgg = new String[hrefElements.size()];
String[] linkks = new String[hrefElements.size()];
for(int i=0;i<hrefElements.size();i++)
{
titlee[i] = hrefElements.get(i).getElementsByClass("listing-title").text();
description[i] = hrefElements.get(i).getElementsByClass("listing-description").text();
distance[i] = hrefElements.get(i).getElementsByClass("listing-location").text();
posted[i] = hrefElements.get(i).getElementsByClass("listing-posted-date").text();
pricee[i] = hrefElements.get(i).getElementsByClass("listing-price").text();
linkks[i] = links.get(i).getElementsByClass("listing-link").text();
}
for(int j=0;j<hrefElements.size();j++)
{
System.out.println("title: "+titlee[j]);
System.out.println("description: "+description[j]);
System.out.println("distance: "+distance[j]);
System.out.println("posted: "+posted[j]);
System.out.println("price: "+pricee[j]);
System.out.println("link: "+linkks[j]);
}
//
//
}
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
here is the html code from a website i got from source code
<div class="listing-content">
<h2 class="listing-title" itemprop="name">
rover mini spi 1275
</h2>
<p class="listing-description truncate-paragraph
hide-fully-to-m"
itemprop="description">
RE ADVERTISED DUE TO SO MANY MESSERS
HERE I HAVE MY ROVER MINI 1275 SPI RECENT RESPRAY AND LOADS OF WELDING
INCLUDING NEW DOORS NEW FRONT END .ETC , IM SELLING THIS DUE TO ILL HEALTH.JUST NEEDS ALL INTERIOR PUTTING BACK IN AND ARCHES PUTTING BACK
</p>
<ul class="listing-attributes inline-list hide-fully-to-m">
<li>
<span class="hide-visually">Year</span><span itemprop=releaseDate>1995</span>
</li>
<li>
<span class="hide-visually">Mileage</span><span itemprop=vehicleMileage>69,000 miles</span>
</li>
<li>
<span class="hide-visually">Fuel type</span><span itemprop=vehicleFuelType>Petrol</span>
</li>
<li>
<span class="hide-visually">Engine size</span><span itemprop=vehicleEngineSize>1,275 cc</span>
</li>
</ul>
<div class="listing-location" itemscope itemtype="http://schema.org/Place">
<span class="truncate-line" itemprop="name">
<span class="hide-visually">Distance from search location: </span>22 miles |
Wilsden, West Yorkshire
</span>
</div>
<strong class="listing-price txt-emphasis"
itemprop="price">£3,000</strong>
<strong class="listing-posted-date txt-normal truncate-line" itemprop="adAge">
<span class="hide-visually">Ad posted </span>
2 days ago
</strong>
</div>
</a>
<span class="save-ad listing-save-ad"
data-savead="channel:savead-1130259301">
<span class="hide-visually">Save this ad</span>
<span class="icn-star iconu-m txt-quaternary" aria-hidden="true"></span>
</span>
</article>
</li>
<li>
<article class="listing-maxi" itemscope itemtype="http://schema.org/Product" data-q=ad-1130231960>
<a class="listing-link" href="/p/spy-racing-motorbikes/road-legal-250cc-quad-low-rider-2011/1130231960" itemprop="url">
<div class="listing-side">
<div class="listing-thumbnail ">
<img src="" data-lazy="https://ssli.ebayimg.com/00/s/NzY4WDEwMjQ=/z/UZkAAOSw9N1V1y23/$_26.JPG"
alt="" itemprop="image"
class="hide-fully-no-js"/>
<noscript>
<img src="https://ssli.ebayimg.com/00/s/NzY4WDEwMjQ=/z/UZkAAOSw9N1V1y23/$_26.JPG" alt="" itemprop="image"/>
</noscript>
</div>
<div class="listing-meta">
<ul class="inline-list txt-center">
<li>4<span class="hide-visually"> images</span>
<span class="icn-camera txt-quaternary" aria-hidden="true"></span>
</li>
</ul>
</div>
</div>
<div class="listing-content">
<h2 class="listing-title" itemprop="name">
Road legal 250cc quad low rider 2011
</h2>
<p class="listing-description truncate-paragraph
hide-fully-to-m"
itemprop="description">
Road legal 250cc quad , 2011, low rider so not your average quad , alloy wheels, real head turner , had to re list due to time waster making me hold it and then decide he doesn't want it , MOT and tax , has service history and full log book , selling
</p>
<ul class="listing-attributes inline-list hide-fully-to-m">
<li>
<span class="hide-visually">Year</span><span itemprop=releaseDate>2011</span>
</li>
<li>
<span class="hide-visually">Mileage</span><span itemprop=vehicleMileage>900 miles</span>
</li>
<li>
<span class="hide-visually">Engine size</span><span itemprop=vehicleEngineSize>226 cc</span>
</li>
</ul>
<div class="listing-location" itemscope itemtype="http://schema.org/Place">
<span class="truncate-line" itemprop="name">
<span class="hide-visually">Distance from search location: </span>8 miles |
Manchester City Centre, Manchester
</span>
</div>
<strong class="listing-price txt-emphasis"
itemprop="price">£1,250</strong>
<strong class="listing-posted-date txt-normal truncate-line" itemprop="adAge">
<span class="hide-visually">Ad posted </span>
2 days ago
</strong>
</div>
</a>
<span class="save-ad listing-save-ad"
data-savead="channel:savead-1130231960">
<span class="hide-visually">Save this ad</span>
<span class="icn-star iconu-m txt-quaternary" aria-hidden="true"></span>
</span>
</article>
</li>
<li>
<article class="listing-maxi" itemscope itemtype="http://schema.org/Product" data-q=ad-1130023447>
<a class="listing-link" href="/p/other-mobile-phone-accessories/touch-screen-phone-sim-smart-watch-spy-camera/1130023447" itemprop="url">
<div class="listing-side">
<div class="listing-thumbnail ">
<img src="" data-lazy="https://ssli.ebayimg.com/00/s/MTAyNFg1NDI=/z/ct0AAOSwPcVV1YAe/$_26.JPG"
alt="" itemprop="image"
class="hide-fully-no-js"/>
<noscript>
<img src="https://ssli.ebayimg.com/00/s/MTAyNFg1NDI=/z/ct0AAOSwPcVV1YAe/$_26.JPG" alt="" itemprop="image"/>
</noscript>
</div>
<div class="listing-meta">
<ul class="inline-list txt-center">
<li>9<span class="hide-visually"> images</span>
<span class="icn-camera txt-quaternary" aria-hidden="true"></span>
</li>
</ul>
</div>
</div>
<div class="listing-content">
<h2 class="listing-title" itemprop="name">
Touch screen phone sim smart watch spy camera
</h2>
<p class="listing-description truncate-paragraph
hide-fully-to-m"
itemprop="description">
Mint condition, Touchscreen smartwatch which works as independent phone, you can put sim card in it.
=Smartwatch with sim card. Full phone with keypad, phone book and SMS
=Can be used as Bluetooth handsfree and for notifications too
=Smart alarm wit
</p>
here is a small part i cut out out of all the html code i want extract listing-link & img src i tried linkks[i] = links.get(i).getElementsByClass("listing-link").text(); but its not getting the link
<article class="listing-maxi" itemscope itemtype="http://schema.org/Product" data-q=ad-1130023447>
<a class="listing-link" href="/p/other-mobile-phone-accessories/touch-screen-phone-sim-smart-watch-spy-camera/1130023447" itemprop="url">
<div class="listing-side">
<div class="listing-thumbnail ">
<img src="" data-lazy="https://ssli.ebayimg.com/00/s/MTAyNFg1NDI=/z/ct0AAOSwPcVV1YAe/$_26.JPG"
alt="" itemprop="image"
class="hide-fully-no-js"/>
<noscript>
<img src="https://ssli.ebayimg.com/00/s/MTAyNFg1NDI=/z/ct0AAOSwPcVV1YAe/$_26.JPG" alt="" itemprop="image"/>
</noscript>