diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e3fbd98 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +build +node_modules diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..a3de0c0 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,13 @@ +{ + "name": "mybahn", + "version": "1.2.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "pebble-clay": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/pebble-clay/-/pebble-clay-1.0.4.tgz", + "integrity": "sha1-/fkvD9x3CpecBodOqiRXzC52I0Q=" + } + } +} diff --git a/src/pkjs/bahn-interface.js b/src/pkjs/bahn-interface.js index 2d43505..944d2db 100644 --- a/src/pkjs/bahn-interface.js +++ b/src/pkjs/bahn-interface.js @@ -1,5 +1,5 @@ var baseUrl = 'http://mobile.bahn.de/bin/query.exe/dox?start=1&rt=1'; -var detailsUrlBase = 'http://reiseauskunft.bahn.de/bin/query2.exe/dox?'; +var detailsUrlBase = 'http://reiseauskunft.bahn.de/bin/query.exe/dox?'; function xhrRequest(url, type, callback) { var xhr = new XMLHttpRequest(); @@ -53,8 +53,8 @@ function extractConnectionResultInfos(text) { var nurZielDelayExp = / * .*]*>(.\d*)]*>/gm; var warnungExp = /
([^<]*)<\/div>/; var spanExp = /<\/?span[^>]*>/gm; - var himDetailsLinkExp = /"(http:\/\/reiseauskunft\.bahn\.de\/bin\/query2\.exe\/dox\?[^"]*&him=[^"]*)"/; + var himDetailsLinkExp = /"(http:\/\/reiseauskunft\.bahn\.de\/bin\/query\.exe\/dox\?[^"]*&him=[^"]*)"/; var htmlTagExp = /<[^<>]*>/gm; var brSurrogateExp = /&#br;/gm; @@ -227,6 +226,8 @@ function extractConnectionDetailInfos(text) { .replace(/ß/gm, "ß") .replace(/ä/gm, "ä") .replace(/ö/gm, "ö") + .replace(/(/gm, "(") + .replace(/)/gm, ")") .replace(/ü/gm, "ü"); return results; @@ -265,8 +266,20 @@ function getConnections(startKey, zielKey, journeyProducts, resultCallback) { function getConnectionDetailInfos(detailLink, resultCallback) { xhrRequest(detailsUrlBase + detailLink, 'GET', function(responseText){ - var result = extractConnectionDetailInfos(responseText); - resultCallback(result); + var matcher=//gm, '&#br;'); + var dlmatch = text.match(matcher); + if (dlmatch) { + console.log(dlmatch) + var detailLink2 = dlmatch[1].replace(ampExp, "&").substring(detailsUrlBase.length); + } + xhrRequest(detailsUrlBase + detailLink2, 'GET', function(responseText){ + var result = extractConnectionDetailInfos(responseText); + resultCallback(result); + }); }); }