i am trying get list of intermediate railway stations information from https://rbs.indianrail.gov.in/ShortPath/ShortPath.jsp, by providing source and destination stations it displays list of intermediate stations within a table. but its hiding some intermediate stations under several buttons to limit the size of the table,i think. on clicking the buttons, it pushes hidden data on to the table. using jsoup i could get initial data in the table. but dont know how to get the hidden data. on button click, one javascript function requesting data using POST method from https://rbs.indianrail.gov.in/ShortPath/StationXmlServlet by passing "route=inter,index=1,distance=goods,PageName=ShortPath" as parameters and the response is in json. as the parameters are not relevant to the displayed table, i can not make direct request to the https://rbs.indianrail.gov.in/ShortPath/StationXmlServlet.
private void shortestPath(String source, String destination) {
Document doc;
try {
doc = Jsoup.connect(url)
.data("srcCode", source.toUpperCase())
.data("destCode", destination.toUpperCase())
.data("guageType", "S")
.data("transhipmentFlag", "false")
.data("distance", "goods")
.post();
Element table = doc.select("tbody").get(0);
Elements rows = table.select("tr");
stationCodeList = new String[rows.size() - 3];
jsonPath = new JSONObject();
for (int row = 3; row < rows.size(); row++) {
JSONObject jsonObject = new JSONObject();
Elements cols = rows.get(row).select("td");
String code = cols.get(1).text();
String name = cols.get(2).text();
String cum_dist = cols.get(3).text();
String inter_dist = cols.get(4).text();
String gauge = cols.get(5).text();
String carry_cap = cols.get(6).text();
jsonObject.put("Code", code);
jsonObject.put("Name", name);
jsonObject.put("Cumulative Distance", cum_dist);
jsonObject.put("inter Distance", inter_dist);
jsonObject.put("Gauge Type", gauge);
jsonObject.put("Carrying Capacity", carry_cap);
jsonPath.put(code, jsonObject);
stationCodeList[row - 3] = code;
}
} catch (Exception e) {
e.printStackTrace();
}
this.destination =new Station(stationCodeList[stationCodeList.length-1]);
}
thank you in advance