mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-19 00:39:58 +00:00
parse SBB connection details
git-svn-id: https://public-transport-enabler.googlecode.com/svn/trunk@61 0924bc21-9374-b0fa-ee44-9ff1593b38f0
This commit is contained in:
parent
669802e746
commit
9abab75816
3 changed files with 278 additions and 14 deletions
|
@ -42,7 +42,7 @@ public class SbbProvider implements NetworkProvider
|
|||
public boolean hasCapabilities(final Capability... capabilities)
|
||||
{
|
||||
for (final Capability capability : capabilities)
|
||||
if (capability != Capability.DEPARTURES)
|
||||
if (capability == Capability.NEARBY_STATIONS)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
@ -93,7 +93,12 @@ public class SbbProvider implements NetworkProvider
|
|||
final StringBuilder uri = new StringBuilder();
|
||||
|
||||
uri.append("http://fahrplan.sbb.ch/bin/query.exe/dn");
|
||||
uri.append("?REQ0HafasInitialSelection=0");
|
||||
uri.append("?OK");
|
||||
uri.append("&REQ0HafasMaxChangeTime=120");
|
||||
uri.append("&REQ0HafasOptimize1=").append(ParserUtils.urlEncode("1:1"));
|
||||
uri.append("&REQ0HafasSearchForw=").append(dep ? "1" : "0");
|
||||
uri.append("&REQ0HafasSkipLongChanges=1");
|
||||
uri.append("&REQ0JourneyDate=").append(ParserUtils.urlEncode(DATE_FORMAT.format(date)));
|
||||
uri.append("&REQ0JourneyStopsS0G=").append(ParserUtils.urlEncode(from));
|
||||
uri.append("&REQ0JourneyStopsS0A=1");
|
||||
uri.append("&REQ0JourneyStopsS0ID=");
|
||||
|
@ -101,15 +106,14 @@ public class SbbProvider implements NetworkProvider
|
|||
{
|
||||
uri.append("&REQ0JourneyStops1.0G=").append(ParserUtils.urlEncode(via));
|
||||
uri.append("&REQ0JourneyStops1.0A=1");
|
||||
uri.append("&REQ0JourneyStops1.0ID=");
|
||||
}
|
||||
uri.append("&REQ0JourneyStopsZ0G=").append(ParserUtils.urlEncode(to));
|
||||
uri.append("&REQ0JourneyStopsZ0A=1");
|
||||
uri.append("&REQ0JourneyStopsZ0ID=");
|
||||
uri.append("&REQ0HafasSearchForw=").append(dep ? "1" : "0");
|
||||
uri.append("&REQ0JourneyDate=").append(ParserUtils.urlEncode(DATE_FORMAT.format(date)));
|
||||
uri.append("&REQ0JourneyTime=").append(ParserUtils.urlEncode(TIME_FORMAT.format(date)));
|
||||
uri.append("&queryPageDisplayed=yes");
|
||||
uri.append("&start=Suchen");
|
||||
|
||||
return uri.toString();
|
||||
}
|
||||
|
||||
|
@ -177,12 +181,31 @@ public class SbbProvider implements NetworkProvider
|
|||
private static final Pattern P_CONNECTIONS_COARSE = Pattern.compile("<tr class=\"(zebra-row-\\d)\">(.*?)</tr>\n?"//
|
||||
+ "<tr class=\"\\1\">(.+?)</tr>", Pattern.DOTALL);
|
||||
private static final Pattern P_CONNECTIONS_FINE = Pattern.compile(".*?" //
|
||||
+ "name=\"guiVCtrl_connection_detailsOut_select_([\\w-]+)\".*?" // id
|
||||
+ ".., (\\d{2}\\.\\d{2}\\.\\d{2}).*?" // departureDate
|
||||
+ "ab.*?(\\d{2}:\\d{2}).*?" // departureTime
|
||||
+ "duration.*?\\d{1,2}:\\d{2}.*?" //
|
||||
+ "(?:.., (\\d{2}\\.\\d{2}\\.\\d{2}).*?)?" // arrivalDate
|
||||
+ "an.*?(\\d{2}:\\d{2}).*?" // arrivalTime
|
||||
, Pattern.DOTALL);
|
||||
private static final Pattern P_CONNECTIONS_DETAILS_COARSE = Pattern.compile("<a name=\"cis_([\\w-]+)\">.*?" // id
|
||||
+ "<table .*? class=\"hac_detail\">\n?<tr>.*?</tr>(.*?)</table>", Pattern.DOTALL);
|
||||
private static final Pattern P_CONNECTION_DETAILS_COARSE = Pattern.compile("<tr>(.*?class=\"stop-station-icon\".*?)</tr>\n?" //
|
||||
+ "<tr>(.*?class=\"stop-station-icon last\".*?)</tr>", Pattern.DOTALL);
|
||||
static final Pattern P_CONNECTION_DETAILS_FINE = Pattern.compile(".*?" //
|
||||
+ "<a href=\"http://fahrplan\\.sbb\\.ch/bin/bhftafel\\.exe/dn.*?input=(\\d+)&.*?\" .*?>" // departureId
|
||||
+ "(.*?)</a>.*?" // departure
|
||||
+ "<td .*?class=\"date.*?>\n?(?:.., (\\d{2}\\.\\d{2}\\.\\d{2})\n?)?</td>.*?" // departureDate
|
||||
+ "<td .*?class=\"time.*?>(?:(\\d{2}:\\d{2})| )</td>.*?" // departureTime
|
||||
+ "<td .*?class=\"platform.*?>\n?\\s*(.+?)?\\s*\n?</td>.*?" // departurePosition
|
||||
+ "<img src=\"/img/2/products/(\\w+?)_pic.gif\" .*? alt=\"(.*?)\".*?>.*?" // line
|
||||
+ "<td .*?class=\"remarks.*?>(?:\n?(\\d+) Min\\..*?)?</td>.*?" // min
|
||||
+ "<a href=\"http://fahrplan\\.sbb\\.ch/bin/bhftafel\\.exe/dn.*?input=(\\d+)&.*?\" .*?>" // arrivalId,
|
||||
+ "(.*?)</a>.*?" // arrival
|
||||
+ "<td .*?class=\"date.*?>\n?(?:.., (\\d{2}\\.\\d{2}\\.\\d{2})\n?)?</td>.*?" // arrivalDate
|
||||
+ "<td .*?class=\"time.*?>(?:(\\d{2}:\\d{2})| )</td>.*?" // arrivalTime
|
||||
+ "<td .*?class=\"platform.*?>\n?\\s*(.+?)?\\s*\n?</td>.*?" // arrivalPosition
|
||||
, Pattern.DOTALL);
|
||||
|
||||
private QueryConnectionsResult queryConnections(final String uri, final CharSequence page) throws IOException
|
||||
{
|
||||
|
@ -197,23 +220,22 @@ public class SbbProvider implements NetworkProvider
|
|||
final List<Connection> connections = new ArrayList<Connection>();
|
||||
|
||||
final Matcher mConCoarse = P_CONNECTIONS_COARSE.matcher(page);
|
||||
int i = 1;
|
||||
while (mConCoarse.find())
|
||||
{
|
||||
final String set = mConCoarse.group(2) + mConCoarse.group(3);
|
||||
final Matcher mConFine = P_CONNECTIONS_FINE.matcher(set);
|
||||
if (mConFine.matches())
|
||||
{
|
||||
final Date departureDate = ParserUtils.parseDate(mConFine.group(1));
|
||||
final Date departureTime = ParserUtils.joinDateTime(departureDate, ParserUtils.parseTime(mConFine.group(2)));
|
||||
final Date arrivalDate = mConFine.group(3) != null ? ParserUtils.parseDate(mConFine.group(3)) : null;
|
||||
final String id = mConFine.group(1);
|
||||
final Date departureDate = ParserUtils.parseDate(mConFine.group(2));
|
||||
final Date departureTime = ParserUtils.joinDateTime(departureDate, ParserUtils.parseTime(mConFine.group(3)));
|
||||
final Date arrivalDate = mConFine.group(4) != null ? ParserUtils.parseDate(mConFine.group(4)) : null;
|
||||
final Date arrivalTime = ParserUtils.joinDateTime(arrivalDate != null ? arrivalDate : departureDate, ParserUtils
|
||||
.parseTime(mConFine.group(4)));
|
||||
final String id = departureTime.toString() + arrivalTime.toString();
|
||||
.parseTime(mConFine.group(5)));
|
||||
final String link = uri + "#" + id; // TODO use print link?
|
||||
|
||||
final Connection connection = new Connection(id, uri + "#" + i++, departureTime, arrivalTime, 0, from, 0, to,
|
||||
final Connection connection = new Connection(id, link, departureTime, arrivalTime, 0, from, 0, to,
|
||||
new ArrayList<Connection.Part>(1));
|
||||
connection.parts.add(new Connection.Trip(departureTime, arrivalTime, null, null));
|
||||
connections.add(connection);
|
||||
}
|
||||
else
|
||||
|
@ -222,6 +244,75 @@ public class SbbProvider implements NetworkProvider
|
|||
}
|
||||
}
|
||||
|
||||
final Matcher mConDetCoarse = P_CONNECTIONS_DETAILS_COARSE.matcher(page);
|
||||
while (mConDetCoarse.find())
|
||||
{
|
||||
final String id = mConDetCoarse.group(1);
|
||||
final Connection connection = findConnection(connections, id);
|
||||
|
||||
Date lastDate = null;
|
||||
|
||||
final Matcher mDetCoarse = P_CONNECTION_DETAILS_COARSE.matcher(mConDetCoarse.group(2));
|
||||
while (mDetCoarse.find())
|
||||
{
|
||||
final String set = mDetCoarse.group(1) + mDetCoarse.group(2);
|
||||
|
||||
final Matcher mDetFine = P_CONNECTION_DETAILS_FINE.matcher(set);
|
||||
if (mDetFine.matches())
|
||||
{
|
||||
final int departureId = Integer.parseInt(mDetFine.group(1));
|
||||
|
||||
final String departure = ParserUtils.resolveEntities(mDetFine.group(2));
|
||||
|
||||
final String lineType = mDetFine.group(6);
|
||||
|
||||
final int arrivalId = Integer.parseInt(mDetFine.group(9));
|
||||
|
||||
final String arrival = ParserUtils.resolveEntities(mDetFine.group(10));
|
||||
|
||||
if (!lineType.equals("fuss") && !lineType.equals("transfer"))
|
||||
{
|
||||
Date departureDate = mDetFine.group(3) != null ? ParserUtils.parseDate(mDetFine.group(3)) : null;
|
||||
if (departureDate != null)
|
||||
lastDate = departureDate;
|
||||
else
|
||||
departureDate = lastDate;
|
||||
|
||||
final Date departureTime = ParserUtils.joinDateTime(departureDate, ParserUtils.parseTime(mDetFine.group(4)));
|
||||
|
||||
final String departurePosition = mDetFine.group(5) != null ? ParserUtils.resolveEntities(mDetFine.group(5)) : null;
|
||||
|
||||
final String line = normalizeLine(lineType, ParserUtils.resolveEntities(mDetFine.group(7)));
|
||||
|
||||
Date arrivalDate = mDetFine.group(11) != null ? ParserUtils.parseDate(mDetFine.group(11)) : null;
|
||||
if (arrivalDate != null)
|
||||
lastDate = arrivalDate;
|
||||
else
|
||||
arrivalDate = lastDate;
|
||||
|
||||
final Date arrivalTime = ParserUtils.joinDateTime(arrivalDate, ParserUtils.parseTime(mDetFine.group(12)));
|
||||
|
||||
final String arrivalPosition = mDetFine.group(13) != null ? ParserUtils.resolveEntities(mDetFine.group(13)) : null;
|
||||
|
||||
final Connection.Trip trip = new Connection.Trip(line, LINES.get(line.charAt(0)), null, departureTime, departurePosition,
|
||||
departureId, departure, arrivalTime, arrivalPosition, arrivalId, arrival);
|
||||
connection.parts.add(trip);
|
||||
}
|
||||
else
|
||||
{
|
||||
final int min = Integer.parseInt(mDetFine.group(8));
|
||||
|
||||
final Connection.Footway footway = new Connection.Footway(min, departure, arrival);
|
||||
connection.parts.add(footway);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException("cannot parse '" + set + "' on " + uri);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new QueryConnectionsResult(uri, from, to, currentDate, linkEarlier, linkLater, connections);
|
||||
}
|
||||
else
|
||||
|
@ -230,6 +321,15 @@ public class SbbProvider implements NetworkProvider
|
|||
}
|
||||
}
|
||||
|
||||
private Connection findConnection(List<Connection> connections, String id)
|
||||
{
|
||||
for (final Connection connection : connections)
|
||||
if (connection.id.equals(id))
|
||||
return connection;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public GetConnectionDetailsResult getConnectionDetails(final String connectionUri) throws IOException
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
|
@ -328,6 +428,41 @@ public class SbbProvider implements NetworkProvider
|
|||
|
||||
private static final Pattern P_NORMALIZE_LINE = Pattern.compile("([A-Za-zÄÖÜäöüß]+)[\\s-]*(.*)");
|
||||
|
||||
private static String normalizeLine(final String type, final String line)
|
||||
{
|
||||
String strippedLine;
|
||||
final Matcher m = P_NORMALIZE_LINE.matcher(line);
|
||||
if (m.matches())
|
||||
strippedLine = m.group(1) + m.group(2);
|
||||
else
|
||||
strippedLine = line;
|
||||
|
||||
if (type.equals("ice")) // InterCityExpress
|
||||
return "I" + strippedLine;
|
||||
if (type.equals("ic")) // InterCity
|
||||
return "I" + strippedLine;
|
||||
if (type.equals("icn")) // Intercity-Neigezug, Schweiz
|
||||
return "I" + strippedLine;
|
||||
if (type.equals("tha")) // Thalys
|
||||
return "I" + strippedLine;
|
||||
if (type.equals("r"))
|
||||
return "R" + strippedLine;
|
||||
if (type.equals("re"))
|
||||
return "R" + strippedLine;
|
||||
if (type.equals("ir"))
|
||||
return "R" + strippedLine;
|
||||
if (type.matches("s\\d*"))
|
||||
return "S" + strippedLine;
|
||||
if (type.equals("tra"))
|
||||
return "T" + strippedLine;
|
||||
if (type.equals("bus"))
|
||||
return "B" + strippedLine;
|
||||
if (type.equals("tro"))
|
||||
return "B" + strippedLine;
|
||||
|
||||
throw new IllegalStateException("cannot normalize type " + type + " line " + line);
|
||||
}
|
||||
|
||||
private static String normalizeLine(final String line)
|
||||
{
|
||||
// TODO IN Torino-Napoli
|
||||
|
|
118
test/de/schildbach/pte/SbbProviderTest.java
Normal file
118
test/de/schildbach/pte/SbbProviderTest.java
Normal file
|
@ -0,0 +1,118 @@
|
|||
/*
|
||||
* Copyright 2010 the original author or authors.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.schildbach.pte;
|
||||
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author Andreas Schildbach
|
||||
*/
|
||||
public class SbbProviderTest
|
||||
{
|
||||
@Test
|
||||
public void tripWithoutDate()
|
||||
{
|
||||
assertFineConnectionDetails("<td headers=\"stops-2\" class=\"stop-station-icon\" valign=\"top\">\n" //
|
||||
+ "<a href=\"http://fahrplan.sbb.ch/bin/query.exe/dn?ld=&i=38.03520220.1281445666&n=1&uscid=14\"><img src=\"/img/2/icon_map_location.gif\" width=\"12\" height=\"12\" border=\"0\" alt=\"Umgebungskarte: Aarau\" hspace=\"3\" style=\"vertical-align:middle;margin-right:4px;\" /></a>\n" //
|
||||
+ "</td>\n" //
|
||||
+ "<td headers=\"stops-2\" class=\"stop-station\">\n" //
|
||||
+ "<a href=\"http://fahrplan.sbb.ch/bin/bhftafel.exe/dn?seqnr=1&ident=38.03520220.1281445666&input=8502113&boardType=dep&time=15:47\" title=\"Haltestelleninformation: Aarau\">Aarau</a></td>\n" //
|
||||
+ "<td headers=\"date-2\" class=\"date\" align=\"left\">\n" //
|
||||
+ "</td>\n" //
|
||||
+ "<td headers=\"time-2\" class=\"time prefix timeLeft\" align=\"left\" nowrap=\"nowrap\">ab</td><td headers=\"time-2\" class=\"time timeRight\" align=\"left\" nowrap=\"nowrap\">15:47</td><td headers=\"platform-2\" class=\"platform\" align=\"left\">\n" //
|
||||
+ "5 \n" //
|
||||
+ "</td>\n" //
|
||||
+ "<td headers=\"products-2\" class=\"products last\" style=\"white-space:nowrap;\" rowspan=\"2\" valign=\"top\">\n" //
|
||||
+ "<img src=\"/img/2/products/ir_pic.gif\" width=\"18\" height=\"18\" alt=\"IR 1928\" style=\"margin-top:2px;\"><br />\n" //
|
||||
+ "<a href=\"http://fahrplan.sbb.ch/bin/traininfo.exe/dn/485775/162441/812040/244101/85?seqnr=1&ident=38.03520220.1281445666&date=10.08.10&station_evaId=8502113&station_type=dep&journeyStartIdx=3&journeyEndIdx=6&\" title=\"Fahrtinformation\">\n" //
|
||||
+ "IR 1928\n" //
|
||||
+ "</a>\n" //
|
||||
+ "</td>\n" //
|
||||
+ "<td headers=\"capacity-2\" class=\"capacity last\" style=\"white-space:nowrap;\" rowspan=\"2\" valign=\"top\">\n" //
|
||||
+ "<div style=\"width:65px;height:15px;line-height:15px;\">\n" //
|
||||
+ "<div style=\"float:left;width:30px;height:15px;line-height:15px;\">\n" //
|
||||
+ "1. <img src=\"/img/2/icon_capacity1.gif\" alt=\"Tiefe bis mittlere Belegung erwartet\" title=\"Tiefe bis mittlere Belegung erwartet\" style=\"border:0px;width:14px;height12:px\" />\n" //
|
||||
+ "</div>\n" //
|
||||
+ "<div style=\"float:left;width:30px;height:15px;line-height:15px;margin-left:4px;\">\n" //
|
||||
+ "2. <img src=\"/img/2/icon_capacity1.gif\" alt=\"Tiefe bis mittlere Belegung erwartet\" title=\"Tiefe bis mittlere Belegung erwartet\" style=\"border:0px;width:14px;height12:px\" />\n" //
|
||||
+ "</div>\n" //
|
||||
+ "</div>\n" //
|
||||
+ "</td>\n" //
|
||||
+ "<td headers=\"remarks-2\" class=\"remarks last\" rowspan=\"2\" valign=\"top\">\n" //
|
||||
+ "InterRegio </td>\n" //
|
||||
+ "\n" //
|
||||
+ "<td headers=\"stops-2\" class=\"stop-station-icon last\" valign=\"top\">\n" //
|
||||
+ "<a href=\"http://fahrplan.sbb.ch/bin/query.exe/dn?ld=&i=38.03520220.1281445666&n=1&uscid=15\"><img src=\"/img/2/icon_map_location.gif\" width=\"12\" height=\"12\" border=\"0\" alt=\"Umgebungskarte: Bern\" hspace=\"3\" style=\"vertical-align:middle;margin-right:4px;\" /></a></td>\n" //
|
||||
+ "<td headers=\"stops-2\" class=\"stop-station last\">\n" //
|
||||
+ "<a href=\"http://fahrplan.sbb.ch/bin/bhftafel.exe/dn?seqnr=1&ident=38.03520220.1281445666&input=8507000&boardType=arr&time=16:25\" title=\"Haltestelleninformation: Bern\">Bern</a></td>\n" //
|
||||
+ "<td headers=\"date-2\" class=\"date last\" align=\"left\">\n" //
|
||||
+ "</td>\n" //
|
||||
+ "<td headers=\"time-2\" class=\"time prefix last timeLeft\" align=\"left\" nowrap=\"nowrap\">an</td><td headers=\"time-2\" class=\"time last timeRight\" align=\"left\" nowrap=\"nowrap\">16:25</td><td headers=\"platform-2\" class=\"platform last\" align=\"left\">\n" //
|
||||
+ "10 \n" //
|
||||
+ "</td>");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void footway()
|
||||
{
|
||||
assertFineConnectionDetails("\n" //
|
||||
+ "<td headers=\"stops-0\" class=\"stop-station-icon\" valign=\"top\">\n" //
|
||||
+ "<a href=\"http://fahrplan.sbb.ch/bin/query.exe/dn?ld=&i=9q.030782220.1281450202&n=1&uscid=10\"><img src=\"/img/2/icon_map_location.gif\" width=\"12\" height=\"12\" border=\"0\" alt=\"Umgebungskarte: Amriswil, Bahnhof\" hspace=\"3\" style=\"vertical-align:middle;margin-right:4px;\" /></a>\n" //
|
||||
+ "</td>\n" //
|
||||
+ "<td headers=\"stops-0\" class=\"stop-station\">\n" //
|
||||
+ "<a href=\"http://fahrplan.sbb.ch/bin/bhftafel.exe/dn?seqnr=1&ident=9q.030782220.1281450202&input=8587138&boardType=dep&time=16:38\" title=\"Haltestelleninformation: Amriswil, Bahnhof\">Amriswil, Bahnhof</a></td>\n" //
|
||||
+ "<td headers=\"date-0\" class=\"date\" align=\"left\">\n" //
|
||||
+ "</td>\n" //
|
||||
+ "<td headers=\"time-0\" class=\"time prefix timeLeft\" align=\"left\" nowrap=\"nowrap\"> </td><td headers=\"time-0\" class=\"time timeRight\" align=\"left\" nowrap=\"nowrap\"> </td><td headers=\"platform-0\" class=\"platform\" align=\"left\">\n" //
|
||||
+ "</td>\n" //
|
||||
+ "<td headers=\"products-0\" class=\"products last\" style=\"white-space:nowrap;\" rowspan=\"2\" valign=\"top\">\n" //
|
||||
+ "<img src=\"/img/2/products/fuss_pic.gif\" width=\"18\" height=\"18\" border=\"0\" vspace=\"2\" alt=\"Fussweg\" /><br />\n" //
|
||||
+ "<a href=\"http://fahrplan.sbb.ch/bin/query.exe/dn?ld=&i=9q.030782220.1281450202&n=1&uscid=11\">Fussweg</a>\n" //
|
||||
+ "</td>\n" //
|
||||
+ "<td headers=\"capacity-0\" class=\"capacity last\" style=\"white-space:nowrap;\" rowspan=\"2\" valign=\"top\">\n" //
|
||||
+ "<div style=\"width:65px;height:15px;line-height:15px;\">\n" //
|
||||
+ "<div style=\"float:left;width:30px;height:15px;line-height:15px;\">\n" //
|
||||
+ "</div>\n" //
|
||||
+ "<div style=\"float:left;width:30px;height:15px;line-height:15px;margin-left:4px;\">\n" //
|
||||
+ "</div>\n" //
|
||||
+ "</div>\n" //
|
||||
+ "</td>\n" //
|
||||
+ "<td headers=\"remarks-0\" class=\"remarks last\" rowspan=\"2\" valign=\"top\">\n" //
|
||||
+ "1 Min., Y </td>\n" //
|
||||
+ "\n" //
|
||||
+ "<td headers=\"stops-0\" class=\"stop-station-icon last\" valign=\"top\">\n" //
|
||||
+ "<a href=\"http://fahrplan.sbb.ch/bin/query.exe/dn?ld=&i=9q.030782220.1281450202&n=1&uscid=12\"><img src=\"/img/2/icon_map_location.gif\" width=\"12\" height=\"12\" border=\"0\" alt=\"Umgebungskarte: Amriswil\" hspace=\"3\" style=\"vertical-align:middle;margin-right:4px;\" /></a></td>\n" //
|
||||
+ "<td headers=\"stops-0\" class=\"stop-station last\">\n" //
|
||||
+ "<a href=\"http://fahrplan.sbb.ch/bin/bhftafel.exe/dn?seqnr=1&ident=9q.030782220.1281450202&input=8506109&boardType=arr&time=16:39\" title=\"Haltestelleninformation: Amriswil\">Amriswil</a></td>\n" //
|
||||
+ "<td headers=\"date-0\" class=\"date last\" align=\"left\">\n" //
|
||||
+ "</td>\n" //
|
||||
+ "<td headers=\"time-0\" class=\"time prefix last timeLeft\" align=\"left\" nowrap=\"nowrap\"> </td><td headers=\"time-0\" class=\"time last timeRight\" align=\"left\" nowrap=\"nowrap\"> </td><td headers=\"platform-0\" class=\"platform last\" align=\"left\">\n" //
|
||||
+ "</td>\n");
|
||||
}
|
||||
|
||||
private void assertFineConnectionDetails(String s)
|
||||
{
|
||||
Matcher m = SbbProvider.P_CONNECTION_DETAILS_FINE.matcher(s);
|
||||
assertTrue(m.matches());
|
||||
// ParserUtils.printGroups(m);
|
||||
}
|
||||
}
|
|
@ -32,9 +32,20 @@ public class SbbProviderLiveTest
|
|||
private SbbProvider provider = new SbbProvider();
|
||||
|
||||
@Test
|
||||
public void connection() throws Exception
|
||||
public void fastConnection() throws Exception
|
||||
{
|
||||
final QueryConnectionsResult result = provider.queryConnections("Zürich!", null, "Bern", new Date(), true);
|
||||
System.out.println(result);
|
||||
final QueryConnectionsResult moreResult = provider.queryMoreConnections(result.linkLater);
|
||||
System.out.println(moreResult);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void slowConnection() throws Exception
|
||||
{
|
||||
final QueryConnectionsResult result = provider.queryConnections("Schocherswil, Alte Post!", null, "Laconnex, Mollach", new Date(), true);
|
||||
System.out.println(result);
|
||||
final QueryConnectionsResult moreResult = provider.queryMoreConnections(result.linkLater);
|
||||
System.out.println(moreResult);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue