mirror of
https://github.com/Threnklyn/myBahn.git
synced 2026-05-18 12:13:30 +02:00
fixed bahn page
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
build
|
||||
node_modules
|
||||
Generated
+13
@@ -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="
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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 = /<td class="overview tprt" *> * .*<span[^>]*>(.\d*)</;
|
||||
var achtungExp = /achtung_17x19_mitschatten.png/;
|
||||
var ausfallExp = /Icon_Zug_faellt_aus_mit_Schatten_17x19.png/;
|
||||
var frueherExp = /(http:\/\/reiseauskunft\.bahn\.de\/bin\/query2\.exe\/dox\?[^"]*amp;e=2[^"]*)"/;
|
||||
var spaeterExp = /(http:\/\/reiseauskunft\.bahn\.de\/bin\/query2\.exe\/dox\?[^"]*&e=1[^"]*)"/;
|
||||
var frueherExp = /(http:\/\/reiseauskunft\.bahn\.de\/bin\/query\.exe\/dox\?[^"]*amp;e=2[^"]*)"/;
|
||||
var spaeterExp = /(http:\/\/reiseauskunft\.bahn\.de\/bin\/query\.exe\/dox\?[^"]*&e=1[^"]*)"/;
|
||||
var ampExp = /&/gm;
|
||||
|
||||
var results = [];
|
||||
@@ -66,7 +66,6 @@ function extractConnectionResultInfos(text) {
|
||||
frueherLink = frueherLink[1].replace(ampExp, "&").substring(detailsUrlBase.length);
|
||||
results.push({moreLink: frueherLink, earlier: true});
|
||||
}
|
||||
|
||||
for (var i = 1; i < resultStrings.length; i++) {
|
||||
var connectionInfo = resultStrings[i].trim();
|
||||
|
||||
@@ -139,7 +138,7 @@ function extractConnectionDetailInfos(text) {
|
||||
var ausfallExp = /<[^<]*Icon_Zug_faellt_aus_mit_Schatten_17x19.png[^>]*>/gm;
|
||||
var warnungExp = /<div class="red bold haupt" *>([^<]*)<\/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,9 +266,21 @@ function getConnections(startKey, zielKey, journeyProducts, resultCallback) {
|
||||
|
||||
function getConnectionDetailInfos(detailLink, resultCallback) {
|
||||
xhrRequest(detailsUrlBase + detailLink, 'GET', function(responseText){
|
||||
var matcher=/<a id="dtlOpen_link" href="([^"]*)"/;
|
||||
var ampExp = /&/gm;
|
||||
text = responseText
|
||||
.replace(/(\r\n)|(\n|\r)|\t/gm, '')
|
||||
.replace(/<br *\/?>/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);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
||||
Reference in New Issue
Block a user