For some reason, when I run the code below with eBay sold listings, I got java.lang.NullPointerException
:
Elements Listings = (Elements) document.getElementsByClass("s-item__details clearfix"); // Each box contains the deal info
for (Element e : Listings) { // Within each box we would like to extract the listing' names and sold prices
String listingName = e.select("h3.s-item__title s-item__title--has-tags").first().text();
System.out.println(listingName);
If I remove the for loop, I will be able to display Listings. What I am trying to do is to extract the listings' names and sold prices. May I know what I am doing wrong please?