mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-17 05:39:51 +00:00
fixed could not parse connection overviews with three table rows
git-svn-id: https://public-transport-enabler.googlecode.com/svn/trunk@161 0924bc21-9374-b0fa-ee44-9ff1593b38f0
This commit is contained in:
parent
313ebe8d02
commit
297a08e7e7
1 changed files with 10 additions and 2 deletions
|
@ -205,8 +205,9 @@ public class SbbProvider implements NetworkProvider
|
||||||
+ "(?:<a href=\"(http://fahrplan.sbb.ch/bin/query.exe/dn[^\"]*?&REQ0HafasScrollDir=2)\".*?)?" // linkEarlier
|
+ "(?:<a href=\"(http://fahrplan.sbb.ch/bin/query.exe/dn[^\"]*?&REQ0HafasScrollDir=2)\".*?)?" // linkEarlier
|
||||||
+ "(?:<a href=\"(http://fahrplan.sbb.ch/bin/query.exe/dn[^\"]*?&REQ0HafasScrollDir=1)\".*?)?" // linkLater
|
+ "(?:<a href=\"(http://fahrplan.sbb.ch/bin/query.exe/dn[^\"]*?&REQ0HafasScrollDir=1)\".*?)?" // linkLater
|
||||||
, Pattern.DOTALL);
|
, Pattern.DOTALL);
|
||||||
private static final Pattern P_CONNECTIONS_COARSE = Pattern.compile("<tr class=\"(zebra-row-\\d)\">(.*?)</tr>\n?"//
|
private static final Pattern P_CONNECTIONS_COARSE = Pattern.compile("<tr class=\"(zebra-row-\\d)\">(.*?)</tr>\n"//
|
||||||
+ "<tr class=\"\\1\">(.+?)</tr>", Pattern.DOTALL);
|
+ "<tr class=\"\\1\">(.*?)</tr>\n"//
|
||||||
|
+ "(?:<tr class=\"\\1\">.*?</tr>\n)?", Pattern.DOTALL);
|
||||||
private static final Pattern P_CONNECTIONS_FINE = Pattern.compile(".*?" //
|
private static final Pattern P_CONNECTIONS_FINE = Pattern.compile(".*?" //
|
||||||
+ "name=\"guiVCtrl_connection_detailsOut_select_([\\w-]+)\".*?" // id
|
+ "name=\"guiVCtrl_connection_detailsOut_select_([\\w-]+)\".*?" // id
|
||||||
+ ".., (\\d{2}\\.\\d{2}\\.\\d{2}).*?" // departureDate
|
+ ".., (\\d{2}\\.\\d{2}\\.\\d{2}).*?" // departureDate
|
||||||
|
@ -248,10 +249,17 @@ public class SbbProvider implements NetworkProvider
|
||||||
final String linkEarlier = mHead.group(4) != null ? ParserUtils.resolveEntities(mHead.group(4)) : null;
|
final String linkEarlier = mHead.group(4) != null ? ParserUtils.resolveEntities(mHead.group(4)) : null;
|
||||||
final String linkLater = mHead.group(5) != null ? ParserUtils.resolveEntities(mHead.group(5)) : null;
|
final String linkLater = mHead.group(5) != null ? ParserUtils.resolveEntities(mHead.group(5)) : null;
|
||||||
final List<Connection> connections = new ArrayList<Connection>();
|
final List<Connection> connections = new ArrayList<Connection>();
|
||||||
|
String oldZebra = null;
|
||||||
|
|
||||||
final Matcher mConCoarse = P_CONNECTIONS_COARSE.matcher(page);
|
final Matcher mConCoarse = P_CONNECTIONS_COARSE.matcher(page);
|
||||||
while (mConCoarse.find())
|
while (mConCoarse.find())
|
||||||
{
|
{
|
||||||
|
final String zebra = mConCoarse.group(1);
|
||||||
|
if (oldZebra != null && zebra.equals(oldZebra))
|
||||||
|
throw new IllegalArgumentException("missed row? last:" + zebra);
|
||||||
|
else
|
||||||
|
oldZebra = zebra;
|
||||||
|
|
||||||
final String set = mConCoarse.group(2) + mConCoarse.group(3);
|
final String set = mConCoarse.group(2) + mConCoarse.group(3);
|
||||||
final Matcher mConFine = P_CONNECTIONS_FINE.matcher(set);
|
final Matcher mConFine = P_CONNECTIONS_FINE.matcher(set);
|
||||||
if (mConFine.matches())
|
if (mConFine.matches())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue