--- android/TrainInfoService/src/dk/thoerup/traininfoservice/banedk/DepartureFetcher.java 2009/09/11 05:32:04 312 +++ android/TrainInfoService/src/dk/thoerup/traininfoservice/banedk/DepartureFetcher.java 2009/09/11 07:13:46 313 @@ -7,6 +7,7 @@ import java.util.Collections; import java.util.List; +import com.gargoylesoftware.htmlunit.ProxyConfig; import com.gargoylesoftware.htmlunit.WebClient; import com.gargoylesoftware.htmlunit.html.DomNodeList; import com.gargoylesoftware.htmlunit.html.HtmlElement; @@ -60,7 +61,8 @@ final WebClient webClient = new WebClient(); webClient.setTimeout(1000); - webClient.setJavaScriptEnabled(false); + webClient.setJavaScriptEnabled(false); + final HtmlPage page = webClient.getPage("http://www.bane.dk/visStation.asp?ArtikelID=4275&W=" + type + "&S=" + stationcode); @@ -95,7 +97,7 @@ String status = fields.get(6).asText(); departure.setStatus(status); - String note = fields.get(7).asText(); + String note = extractNote( fields.get(7) ); departure.setNote(note); departureList.add(departure); @@ -123,6 +125,16 @@ return updated; } + private String extractNote(HtmlElement noteTd) { + String note = noteTd.asText().trim(); + + List elems = noteTd.getElementsByAttribute("span", "class", "bemtype"); + if (elems.size() > 0 && note.charAt(note.length()-1) == 'i') + note = note.substring(0,note.length() -1 ); + + return note; + } + //test public static void main(String args[]) throws Exception{ DepartureFetcher f = new DepartureFetcher();