--- android/TrainInfoService/src/dk/thoerup/traininfoservice/banedk/DepartureFetcher.java 2010/07/14 08:05:31 992 +++ android/TrainInfoService/src/dk/thoerup/traininfoservice/banedk/DepartureFetcher.java 2010/08/30 11:53:34 1020 @@ -2,6 +2,7 @@ import java.net.URL; +import java.net.URLEncoder; import java.util.Collections; import java.util.Map; import java.util.logging.Logger; @@ -108,10 +109,13 @@ String typeString = getTypeString(type); String arrivalDeparture = (arrival==false) ? "Afgang" : "Ankomst"; - + + stationcode = URLEncoder.encode(stationcode,"ISO-8859-1"); //String uri = "http://www.bane.dk/visStation.asp?ArtikelID=4275&W=" + type + "&S=" + stationcode; String uri = "http://trafikinfo.bane.dk/Trafikinformation/AfgangAnkomst/" + arrivalDeparture + "/" + stationcode + "/" + typeString + "/UdvidetVisning"; + + //logger.info("URI: " + uri); JsoupInvocation wrapper = new JsoupInvocation( new URL(uri), 2500); CircuitBreaker breaker = CircuitBreakerManager.getManager().getCircuitBreaker("banedk"); @@ -124,9 +128,22 @@ if (table != null) { Elements tableRows = table.getElementsByTag("tr"); + boolean tidsstregExists = (table.getElementsByAttributeValue("class", "Tidsstreg").size() > 0); + boolean passedTidsstreg = false; + 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"); DepartureEntry departure = new DepartureEntry();