I want to get the data from the datatable which is available in this url mentioned.
This is not working for this url only for other url it is working fine.
This is the code for web scraping but the issue is that it is not working that that url.
import java.io.IOException;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
public class GetData {
public static void main(String[] args) throws InterruptedException {
String html = "http://programs.dsireusa.org/system/program";
try {
Document doc = Jsoup.connect(html).get();
Elements tableElements = doc.select("table");
Elements tableHeaderEles = tableElements.select("thead tr th");
System.out.println("headers");
Thread.sleep(5000);
System.out.println(tableHeaderEles.size());
for (int i = 0; i < tableHeaderEles.size(); i++) {
System.out.println(tableHeaderEles.get(i).text());
}
System.out.println();
Elements tableRowElements = tableElements.select(":not(thead) tr");
for (int i = 0; i < tableRowElements.size(); i++) {
Element row = tableRowElements.get(i);
System.out.println("row");
Elements rowItems = row.select("td");
for (int j = 0; j < rowItems.size(); j++) {
System.out.println(rowItems.get(j).text());
}
System.out.println();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
I expect the output of all the data available in the datatable of this url this program is working fine for other other url.