--- android/TrainInfoService/src/dk/thoerup/traininfoservice/banedk/DepartureFetcher.java 2010/09/12 19:37:56 1040 +++ android/TrainInfoService/src/dk/thoerup/traininfoservice/banedk/DepartureFetcher.java 2010/09/14 05:33:30 1046 @@ -231,8 +231,11 @@ String type = getTypeStringWww(trainType); + stationcode = URLEncoder.encode(stationcode, "ISO-8859-1"); + String uri = "http://www.bane.dk/visStation.asp?ArtikelID=4275&W=" + type + "&S=" + stationcode; + logger.info("URI:" + uri); JsoupInvocation wrapper = new JsoupInvocation( new URL(uri), replyTimeout); CircuitBreaker breaker = CircuitBreakerManager.getManager().getCircuitBreaker("banedk"); @@ -241,11 +244,26 @@ String tableName = arrival == false ? "afgangtabel" : "ankomsttabel"; Element table = page.getElementById(tableName); + + if (table != null) { Elements tableRows = table.getElementsByTag("tr"); + boolean passedTidsstreg = false; + boolean tidsstregExists = (table.getElementsByAttributeValue("class", "Tidsstreg").size() > 0); + for (Element currentRow : tableRows) { String rowClass = currentRow.attr("class"); + + if (tidsstregExists == true && passedTidsstreg == false) { + if (currentRow.getElementsByAttributeValue("class", "Tidsstreg").size() > 0) { + passedTidsstreg = true; + } else { + continue; + } + } + + if (rowClass != null && rowClass.toLowerCase().contains("station") ) { Elements fields = currentRow.getElementsByTag("td");