67 |
final HtmlPage page = webClient.getPage("http://www.bane.dk/visStation.asp?ArtikelID=4275&W=" + type + "&S=" + stationcode); |
final HtmlPage page = webClient.getPage("http://www.bane.dk/visStation.asp?ArtikelID=4275&W=" + type + "&S=" + stationcode); |
68 |
|
|
69 |
HtmlElement table = page.getElementById("afgangtabel"); |
HtmlElement table = page.getElementById("afgangtabel"); |
|
DomNodeList<HtmlElement> tableRows = table.getElementsByTagName("tr"); |
|
70 |
|
|
71 |
for (HtmlElement currentRow : tableRows) { |
if (table != null) { |
72 |
String rowClass = currentRow.getAttribute("class"); |
DomNodeList<HtmlElement> tableRows = table.getElementsByTagName("tr"); |
73 |
if (rowClass != null && rowClass.toLowerCase().contains("station") ) { |
|
74 |
DomNodeList<HtmlElement> fields = currentRow.getElementsByTagName("td"); |
for (HtmlElement currentRow : tableRows) { |
75 |
|
String rowClass = currentRow.getAttribute("class"); |
76 |
DepartureBean departure = new DepartureBean(); |
if (rowClass != null && rowClass.toLowerCase().contains("station") ) { |
77 |
|
DomNodeList<HtmlElement> fields = currentRow.getElementsByTagName("td"); |
78 |
String time = fields.get(0).asText(); |
|
79 |
departure.setTime(time); |
DepartureBean departure = new DepartureBean(); |
80 |
|
|
81 |
int updated = extractUpdated( fields.get(1) ); |
String time = fields.get(0).asText(); |
82 |
departure.setUpdated(updated); |
departure.setTime(time); |
83 |
|
|
84 |
String trainNumber = fields.get(2).asText(); |
int updated = extractUpdated( fields.get(1) ); |
85 |
departure.setTrainNumber(trainNumber); |
departure.setUpdated(updated); |
86 |
|
|
87 |
String destination = fields.get(3).asText(); |
String trainNumber = fields.get(2).asText(); |
88 |
departure.setDestination(destination); |
departure.setTrainNumber(trainNumber); |
89 |
|
|
90 |
String origin = fields.get(4).asText(); |
String destination = fields.get(3).asText(); |
91 |
departure.setOrigin(origin); |
departure.setDestination(destination); |
92 |
|
|
93 |
String location = fields.get(5).asText(); |
String origin = fields.get(4).asText(); |
94 |
departure.setLocation(location); |
departure.setOrigin(origin); |
95 |
|
|
96 |
String status = fields.get(6).asText(); |
String location = fields.get(5).asText(); |
97 |
departure.setStatus(status); |
departure.setLocation(location); |
98 |
|
|
99 |
String note = extractNote( fields.get(7) ); |
String status = fields.get(6).asText(); |
100 |
departure.setNote(note); |
departure.setStatus(status); |
101 |
|
|
102 |
departureList.add(departure); |
String note = extractNote( fields.get(7) ); |
103 |
} |
departure.setNote(note); |
104 |
|
|
105 |
|
departureList.add(departure); |
106 |
|
} |
107 |
|
} |
108 |
} |
} |
|
|
|
109 |
return departureList; |
return departureList; |
110 |
} |
} |
111 |
|
|