curl ->json Ergebnis zusammen führen ?

Meteorologe

Ensign
Registriert
Aug. 2006
Beiträge
254
Hallo,

ich rufe seit etwa zwei Monaten unregelmäßig Daten von http://reseplanerare.resrobot.se/bin/help.exe/sn?L=vs_resrobot& mit curl ab.

curl 'http://reseplanerare.resrobot.se/bin/mgate.exe' -XPOST -H 'DNT: 1' -H 'Content-Type: application/x-www-form-urlencoded' -H 'Referer: http://reseplanerare.resrobot.se/bin/help.exe/sn?L=vs_resrobot&tpl=webapp&' -H 'Origin: http://reseplanerare.resrobot.se' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/602.4.8 (KHTML, like Gecko) Version/10.0.3 Safari/602.4.8' --data '{"ver":"1.10","lang":"swe","auth":{"type":"AID","aid":"h5o3n7f4t2m8l9x1"},"client":{"id":"SAMTRAFIKEN","type":"WEB","name":"Resrobot","v":"3.0.0","l":"vs_resrobot"},"formatted":false,"svcReqL":[{"meth":"JourneyDetails","req":{"jid":"1|5532|0|80|5032017"}}],"ext":"SAM.3.0"}'| jq

Leider ist die Ausgabe sehr unübersichtlich. Trotz einiger "Versuche", komme ich nicht auf das unten beschriebene gewünschte Ergebnis.

-> Wie bekommt man es hin (falls überhaupt möglich), dass die Uhzeitinfo dem jeweiligen Stationsnamen zugeordnet (und auch direkt unterhalb des Stationsnamen) angezeigt wird? Die Abzählung, welche Uhrzeitinfo zu welchem Stationsnamen gehören könnte, ist auf Dauer etwas umständlich.

Folgende Ideen hatte ich, nur es wird (logischerweise) ebenfalls alles untereinander angezeigt.
Reine Anzeige der Stationsnamen:
| jq '.svcResL[0].res.common.locL[].name'
Anzeige der "Uhrzeitinfos":
| jq '.svcResL[0].res.journey.stopL[]'


Vielen Dank für die Hilfe.
 
Zuletzt bearbeitet:
Kannst du nicht wenigstens eine Beispielausgabe (der Seite) mit angeben? Keiner der Links gibt irgendwas in die Richtung aus. 1. sogar nur ein Fehler ;)
Aber die Ausgabe ist in json? Wieso dann nicht einfach parsen, und dann mit ner Schleife die jeweiligen Paare ausgeben? Ich verstehe irgendwie dein Problem nicht. Welche Sprache verwendest du überhaupt? Oder nur CLI?
 
Danke für die flotte Antwort. In der Tat führte curl zu einem error. Das Forum hat wohl irgendwo eine Autokorrektur durchgeführt. Ich habe die Eingabe etwas geändert (sieht nun nicht mehr so schön aus).

Ausgabe sieht folgendermaßen aus:
PHP:
{
  "ver": "1.10",
  "ext": "SAM.3.0",
  "lang": "swe",
  "id": "aj2xsxvmi2gu92ww",
  "svcResL": [
    {
      "id": "",
      "meth": "JourneyDetails",
      "err": "OK",
      "res": {
        "common": {
          "locL": [
            {
              "lid": "A=1@O=Stockholm C Klarabergsviadukte@X=18058376@Y=59331107@U=80@L=740004383@",
              "type": "S",
              "name": "Stockholm C Klarabergsviadukte",
              "icoX": 2,
              "extId": "740004383",
              "crd": {
                "x": 18058376,
                "y": 59331107
              },
              "pCls": 128
            },
            {
              "lid": "A=1@O=Stockholm Sergels Torg@X=18063437@Y=59332464@U=80@L=740024382@",
              "type": "S",
              "name": "Stockholm Sergels Torg",
              "icoX": 2,
              "extId": "740024382",
              "crd": {
                "x": 18063437,
                "y": 59332464
              },
              "pCls": 128
            },
            {
              "lid": "A=1@O=Stockholm Kungsträdgården@X=18071266@Y=59332788@U=80@L=740037355@",
              "type": "S",
              "name": "Stockholm Kungsträdgården",
              "icoX": 2,
              "extId": "740037355",
              "crd": {
                "x": 18071266,
                "y": 59332788
              },
              "pCls": 192
            },
            {
              "lid": "A=1@O=Stockholm Nybroplan@X=18076552@Y=59332734@U=80@L=740019408@",
              "type": "S",
              "name": "Stockholm Nybroplan",
              "icoX": 2,
              "extId": "740019408",
              "crd": {
                "x": 18076552,
                "y": 59332734
              },
              "pCls": 192
            },
            {
              "lid": "A=1@O=Stockholm Styrmansgatan@X=18084633@Y=59331583@U=80@L=740046065@",
              "type": "S",
              "name": "Stockholm Styrmansgatan",
              "icoX": 2,
              "extId": "740046065",
              "crd": {
                "x": 18084633,
                "y": 59331583
              },
              "pCls": 192
            },
            {
              "lid": "A=1@O=Stockholm Djurgårdsbron@X=18093488@Y=59331826@U=80@L=740046036@",
              "type": "S",
              "name": "Stockholm Djurgårdsbron",
              "icoX": 2,
              "extId": "740046036",
              "crd": {
                "x": 18093488,
                "y": 59331826
              },
              "pCls": 192
            },
            {
              "lid": "A=1@O=Berwaldhallen (Stockholm kn)@X=18098773@Y=59333102@U=80@L=740045991@",
              "type": "S",
              "name": "Berwaldhallen (Stockholm kn)",
              "icoX": 2,
              "extId": "740045991",
              "crd": {
                "x": 18098773,
                "y": 59333102
              },
              "pCls": 128
            },
            {
              "lid": "A=1@O=Ambassaderna (Stockholm kn)@X=18104158@Y=59333237@U=80@L=740046239@",
              "type": "S",
              "name": "Ambassaderna (Stockholm kn)",
              "icoX": 2,
              "extId": "740046239",
              "crd": {
                "x": 18104158,
                "y": 59333237
              },
              "pCls": 128
            },
            {
              "lid": "A=1@O=Källhagen (Stockholm kn)@X=18110963@Y=59333552@U=80@L=740046240@",
              "type": "S",
              "name": "Källhagen (Stockholm kn)",
              "icoX": 2,
              "extId": "740046240",
              "crd": {
                "x": 18110963,
                "y": 59333552
              },
              "pCls": 128
            },
            {
              "lid": "A=1@O=Sjöhistoriska museet (Stockholm kn)@X=18115215@Y=59333498@U=80@L=740046241@",
              "type": "S",
              "name": "Sjöhistoriska museet (Stockholm kn)",
              "icoX": 2,
              "extId": "740046241",
              "crd": {
                "x": 18115215,
                "y": 59333498
              },
              "pCls": 128
            },
            {
              "lid": "A=1@O=Museiparken (Stockholm kn)@X=18119062@Y=59333237@U=80@L=740046242@",
              "type": "S",
              "name": "Museiparken (Stockholm kn)",
              "icoX": 2,
              "extId": "740046242",
              "crd": {
                "x": 18119062,
                "y": 59333237
              },
              "pCls": 128
            },
            {
              "lid": "A=1@O=Stockholm Kaknästornet Södra@X=18124833@Y=59333570@U=80@L=740018283@",
              "type": "S",
              "name": "Stockholm Kaknästornet Södra",
              "icoX": 2,
              "extId": "740018283",
              "crd": {
                "x": 18124833,
                "y": 59333570
              },
              "pCls": 128
            },
            {
              "lid": "A=1@O=Kaknäs (Stockholm kn)@X=18128177@Y=59332842@U=80@L=740046243@",
              "type": "S",
              "name": "Kaknäs (Stockholm kn)",
              "icoX": 2,
              "extId": "740046243",
              "crd": {
                "x": 18128177,
                "y": 59332842
              },
              "pCls": 128
            },
            {
              "lid": "A=1@O=Stockholm Kaknästornet@X=18126406@Y=59334702@U=80@L=740020556@",
              "type": "S",
              "name": "Stockholm Kaknästornet",
              "icoX": 2,
              "extId": "740020556",
              "crd": {
                "x": 18126406,
                "y": 59334702
              },
              "pCls": 128
            }
          ],
          "prodL": [
            {
              "name": "Länstrafik - Buss 69",
              "number": "69",
              "line": "69",
              "icoX": 1,
              "cls": 128,
              "oprX": 0,
              "prodCtx": {
                "name": "BLT   69",
                "num": "81909",
                "line": "69",
                "catOut": "BLT     ",
                "catOutS": "BLT",
                "catOutL": "Länstrafik - Buss",
                "catIn": "BLT",
                "catCode": "7"
              }
            }
          ],
          "opL": [
            {
              "name": "SL",
              "url": "http://www.sl.se",
              "icoX": 0
            }
          ],
          "remL": [],
          "icoL": [
            {
              "res": "275",
              "txt": "SL"
            },
            {
              "res": "PCL7",
              "txt": "69"
            },
            {
              "res": "STA"
            }
          ]
        },
        "journey": {
          "jid": "1|5532|0|80|5032017",
          "date": "20170305",
          "prodX": 0,
          "dirTxt": "Stockholm Kaknästornet",
          "dirFlg": "1",
          "status": "P",
          "isRchbl": true,
          "stopL": [
            {
              "locX": 0,
              "idx": 0,
              "dProdX": 0,
              "dTimeS": "143800",
              "dProgType": "PROGNOSED",
              "isImp": true
            },
            {
              "locX": 1,
              "idx": 1,
              "aProdX": 0,
              "aTimeS": "144000",
              "dProdX": 0,
              "dTimeS": "144000",
              "isImp": true
            },
            {
              "locX": 2,
              "idx": 2,
              "aProdX": 0,
              "aTimeS": "144300",
              "dProdX": 0,
              "dTimeS": "144300",
              "isImp": true
            },
            {
              "locX": 3,
              "idx": 3,
              "aProdX": 0,
              "aTimeS": "144600",
              "dProdX": 0,
              "dTimeS": "144600",
              "isImp": true
            },
            {
              "locX": 4,
              "idx": 4,
              "aProdX": 0,
              "aTimeS": "144900",
              "dProdX": 0,
              "dTimeS": "144900",
              "isImp": true
            },
            {
              "locX": 5,
              "idx": 5,
              "aProdX": 0,
              "aTimeS": "145400",
              "dProdX": 0,
              "dTimeS": "145400"
            },
            {
              "locX": 6,
              "idx": 6,
              "aProdX": 0,
              "aTimeS": "145500",
              "dProdX": 0,
              "dTimeS": "145500"
            },
            {
              "locX": 7,
              "idx": 7,
              "aProdX": 0,
              "aTimeS": "145600",
              "dProdX": 0,
              "dTimeS": "145600"
            },
            {
              "locX": 8,
              "idx": 8,
              "aProdX": 0,
              "aTimeS": "145700",
              "dProdX": 0,
              "dTimeS": "145700"
            },
            {
              "locX": 9,
              "idx": 9,
              "aProdX": 0,
              "aTimeS": "145700",
              "dProdX": 0,
              "dTimeS": "145700"
            },
            {
              "locX": 10,
              "idx": 10,
              "aProdX": 0,
              "aTimeS": "145900",
              "dProdX": 0,
              "dTimeS": "145900"
            },
            {
              "locX": 11,
              "idx": 11,
              "aProdX": 0,
              "aTimeS": "150000",
              "dProdX": 0,
              "dTimeS": "150000"
            },
            {
              "locX": 12,
              "idx": 12,
              "aProdX": 0,
              "aTimeS": "150100",
              "dProdX": 0,
              "dTimeS": "150100"
            },
            {
              "locX": 13,
              "idx": 13,
              "aProdX": 0,
              "aTimeS": "150400",
              "aProgType": "PROGNOSED"
            }
          ],
          "sDaysL": [
            {
              "sDaysR": "inte varje dag",
              "sDaysI": "5. mar t o m 23. apr 2017 lör, sön; utom 22. apr; och 14., 17. apr",
              "sDaysB": "0C183060C1878200000000000000",
              "fLocX": 0,
              "tLocX": 13
            }
          ],
          "poly": {
            "name": "standard",
            "delta": true,
            "dim": 2,
            "type": "WGS84",
            "crdEncYX": "kbciJy_fmBoGs^_A}o@Ha`@dFoq@o@iv@_Ga`@Ys`@_Aqi@JqYr@aWcAac@pC{SsJ`J",
            "crdEncZ": "",
            "crdEncS": "NNNNNNNNNNNNNN",
            "ppLocRefL": [
              {
                "ppIdx": 0,
                "locX": 0
              },
              {
                "ppIdx": 1,
                "locX": 1
              },
              {
                "ppIdx": 2,
                "locX": 2
              },
              {
                "ppIdx": 3,
                "locX": 3
              },
              {
                "ppIdx": 4,
                "locX": 4
              },
              {
                "ppIdx": 5,
                "locX": 5
              },
              {
                "ppIdx": 6,
                "locX": 6
              },
              {
                "ppIdx": 7,
                "locX": 7
              },
              {
                "ppIdx": 8,
                "locX": 8
              },
              {
                "ppIdx": 9,
                "locX": 9
              },
              {
                "ppIdx": 10,
                "locX": 10
              },
              {
                "ppIdx": 11,
                "locX": 11
              },
              {
                "ppIdx": 12,
                "locX": 12
              },
              {
                "ppIdx": 13,
                "locX": 13
              }
            ]
          }
        },
        "fpB": "20170228",
        "fpE": "20170618"
      },
      "errTxt": ""
    }
  ]
}

Zuerst erfolgt eine Auflistung der Stationsnamen und dann die Auflistung der Uhrzeitinfos. Da jeweils alles untereinander aufgelistet wird, kann man damit wenig "arbeiten".

Ich verwende curl, da dies von der Homepage verwendet wird und zu keinen Komplikationen o.ä. führt, was meine Arbeit zerstören könnte ;)
 
Zuletzt bearbeitet:
Abfrage:

Code:
curl 'http://reseplanerare.resrobot.se/bin/mgate.exe' \
-XPOST \
-H 'DNT: 1' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-H 'Referer: http://reseplanerare.resrobot.se/bin/help.exe/sn?L=vs_resrobot&tpl=webapp&' \
-H 'Origin: http://reseplanerare.resrobot.se' \
-H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/602.4.8 (KHTML, like Gecko) Version/10.0.3 Safari/602.4.8' \
--data '{"ver":"1.10","lang":"swe","auth":{"type":"AID","aid":"h5o3n7f4t2m8l9x1"},"client":{"id":"SAMTRAFIKEN","type":"WEB","name":"Resrobot","v":"3.0.0","l":"vs_resrobot"},"formatted":false,"svcReqL":[{"meth":"JourneyDetails","req":{"jid":"1|132637|1|80|5032017"}}],"ext":"SAM.3.0"}' | jq

Ergebnis:

Code:
{
  "ver": "1.10",
  "ext": "SAM.3.0",
  "lang": "swe",
  "id": "ac2k4xpkg2gb9g44",
  "svcResL": [
    {
      "id": "",
      "meth": "JourneyDetails",
      "err": "OK",
      "res": {
        "common": {
          "locL": [
            {
              "lid": "A=1@O=Kulturskolans hus (Stockholm kn)@X=18025089@Y=59334774@U=80@L=740046056@",
              "type": "S",
              "name": "Kulturskolans hus (Stockholm kn)",
              "icoX": 2,
              "extId": "740046056",
              "crd": {
                "x": 18025089,
                "y": 59334774
              },
              "pCls": 128
            },
            {
              "lid": "A=1@O=Fridhemsplan T-bana (Stockholm kn)@X=18029188@Y=59332203@U=80@L=740021661@",
              "type": "S",
              "name": "Fridhemsplan T-bana (Stockholm kn)",
              "icoX": 2,
              "extId": "740021661",
              "crd": {
                "x": 18029188,
                "y": 59332203
              },
              "pCls": 168
            },
            {
              "lid": "A=1@O=S*3At Eriksgatan (Fleminggatan) (Stockholm kn)@X=18032145@Y=59334648@U=80@L=740045952@",
              "type": "S",
              "name": "S:t Eriksgatan (Fleminggatan) (Stockholm kn)",
              "icoX": 2,
              "extId": "740045952",
              "crd": {
                "x": 18032145,
                "y": 59334648
              },
              "pCls": 128
            },
            {
              "lid": "A=1@O=S*3At Eriks ögonsjukhus (Stockholm kn)@X=18038204@Y=59333758@U=80@L=740045954@",
              "type": "S",
              "name": "S:t Eriks ögonsjukhus (Stockholm kn)",
              "icoX": 2,
              "extId": "740045954",
              "crd": {
                "x": 18038204,
                "y": 59333758
              },
              "pCls": 128
            },
            {
              "lid": "A=1@O=Scheelegatan (Stockholm kn)@X=18044155@Y=59332967@U=80@L=740045955@",
              "type": "S",
              "name": "Scheelegatan (Stockholm kn)",
              "icoX": 2,
              "extId": "740045955",
              "crd": {
                "x": 18044155,
                "y": 59332967
              },
              "pCls": 128
            },
            {
              "lid": "A=1@O=Kungsbroplan (Stockholm kn)@X=18048407@Y=59332401@U=80@L=740045956@",
              "type": "S",
              "name": "Kungsbroplan (Stockholm kn)",
              "icoX": 2,
              "extId": "740045956",
              "crd": {
                "x": 18048407,
                "y": 59332401
              },
              "pCls": 128
            },
            {
              "lid": "A=1@O=Stockholm Citytermin Kungsbron@X=18054313@Y=59333192@U=80@L=740001541@",
              "type": "S",
              "name": "Stockholm Citytermin Kungsbron",
              "icoX": 2,
              "extId": "740001541",
              "crd": {
                "x": 18054313,
                "y": 59333192
              },
              "pCls": 128
            },
            {
              "lid": "A=1@O=Kungsgatan (Stockholm kn)@X=18056965@Y=59333345@U=80@L=740046064@",
              "type": "S",
              "name": "Kungsgatan (Stockholm kn)",
              "icoX": 2,
              "extId": "740046064",
              "crd": {
                "x": 18056965,
                "y": 59333345
              },
              "pCls": 128
            },
            {
              "lid": "A=1@O=Stockholm Central Vasagatan@X=18059787@Y=59330343@U=80@L=740023844@",
              "type": "S",
              "name": "Stockholm Central Vasagatan",
              "icoX": 2,
              "extId": "740023844",
              "crd": {
                "x": 18059787,
                "y": 59330343
              },
              "pCls": 128
            },
            {
              "lid": "A=1@O=Tegelbacken (Stockholm kn)@X=18062340@Y=59328545@U=80@L=740046083@",
              "type": "S",
              "name": "Tegelbacken (Stockholm kn)",
              "icoX": 2,
              "extId": "740046083",
              "crd": {
                "x": 18062340,
                "y": 59328545
              },
              "pCls": 128
            },
            {
              "lid": "A=1@O=Gustav Adolfs torg (Stockholm kn)@X=18068875@Y=59329848@U=80@L=740046197@",
              "type": "S",
              "name": "Gustav Adolfs torg (Stockholm kn)",
              "icoX": 2,
              "extId": "740046197",
              "crd": {
                "x": 18068875,
                "y": 59329848
              },
              "pCls": 128
            },
            {
              "lid": "A=1@O=Slottsbacken (Stockholm kn)@X=18074898@Y=59326145@U=80@L=740046002@",
              "type": "S",
              "name": "Slottsbacken (Stockholm kn)",
              "icoX": 2,
              "extId": "740046002",
              "crd": {
                "x": 18074898,
                "y": 59326145
              },
              "pCls": 128
            },
            {
              "lid": "A=1@O=Räntmästartrappan (Stockholm kn)@X=18074458@Y=59322189@U=80@L=740046003@",
              "type": "S",
              "name": "Räntmästartrappan (Stockholm kn)",
              "icoX": 2,
              "extId": "740046003",
              "crd": {
                "x": 18074458,
                "y": 59322189
              },
              "pCls": 128
            },
            {
              "lid": "A=1@O=Slussen T-bana (Stockholm kn)@X=18072327@Y=59319493@U=80@L=740020101@",
              "type": "S",
              "name": "Slussen T-bana (Stockholm kn)",
              "icoX": 2,
              "extId": "740020101",
              "crd": {
                "x": 18072327,
                "y": 59319493
              },
              "pCls": 160
            },
            {
              "lid": "A=1@O=Medborgarplatsen (Folkungag) (Stockholm kn)@X=18074889@Y=59314450@U=80@L=740046199@",
              "type": "S",
              "name": "Medborgarplatsen (Folkungag) (Stockholm kn)",
              "icoX": 2,
              "extId": "740046199",
              "crd": {
                "x": 18074889,
                "y": 59314450
              },
              "pCls": 128
            },
            {
              "lid": "A=1@O=Nytorgsgatan (Stockholm kn)@X=18081164@Y=59315025@U=80@L=740046198@",
              "type": "S",
              "name": "Nytorgsgatan (Stockholm kn)",
              "icoX": 2,
              "extId": "740046198",
              "crd": {
                "x": 18081164,
                "y": 59315025
              },
              "pCls": 128
            },
            {
              "lid": "A=1@O=Ersta sjukhus (Stockholm kn)@X=18089910@Y=59315501@U=80@L=740046051@",
              "type": "S",
              "name": "Ersta sjukhus (Stockholm kn)",
              "icoX": 2,
              "extId": "740046051",
              "crd": {
                "x": 18089910,
                "y": 59315501
              },
              "pCls": 128
            },
            {
              "lid": "A=1@O=Londonviadukten (Stockholm kn)@X=18096787@Y=59314746@U=80@L=740046141@",
              "type": "S",
              "name": "Londonviadukten (Stockholm kn)",
              "icoX": 2,
              "extId": "740046141",
              "crd": {
                "x": 18096787,
                "y": 59314746
              },
              "pCls": 128
            },
            {
              "lid": "A=1@O=Danvikstull (Stockholm kn)@X=18100697@Y=59313955@U=80@L=740046143@",
              "type": "S",
              "name": "Danvikstull (Stockholm kn)",
              "icoX": 2,
              "extId": "740046143",
              "crd": {
                "x": 18100697,
                "y": 59313955
              },
              "pCls": 128
            },
            {
              "lid": "A=1@O=Henriksdal station (Stockholm kn)@X=18108158@Y=59312274@U=80@L=740024806@",
              "type": "S",
              "name": "Henriksdal station (Stockholm kn)",
              "icoX": 2,
              "extId": "740024806",
              "crd": {
                "x": 18108158,
                "y": 59312274
              },
              "pCls": 144
            },
            {
              "lid": "A=1@O=Danviksklippan (Stockholm kn)@X=18106082@Y=59312526@U=80@L=740046144@",
              "type": "S",
              "name": "Danviksklippan (Stockholm kn)",
              "icoX": 2,
              "extId": "740046144",
              "crd": {
                "x": 18106082,
                "y": 59312526
              },
              "pCls": 128
            },
            {
              "lid": "A=1@O=Danviken (Nacka kn)@X=18108581@Y=59313047@U=80@L=740046147@",
              "type": "S",
              "name": "Danviken (Nacka kn)",
              "icoX": 2,
              "extId": "740046147",
              "crd": {
                "x": 18108581,
                "y": 59313047
              },
              "pCls": 128
            },
            {
              "lid": "A=1@O=Saltsjöqvarn (Stockholm kn)@X=18111143@Y=59314324@U=80@L=740046145@",
              "type": "S",
              "name": "Saltsjöqvarn (Stockholm kn)",
              "icoX": 2,
              "extId": "740046145",
              "crd": {
                "x": 18111143,
                "y": 59314324
              },
              "pCls": 128
            },
            {
              "lid": "A=1@O=Danvikshem (Nacka kn)@X=18115979@Y=59314216@U=80@L=740046148@",
              "type": "S",
              "name": "Danvikshem (Nacka kn)",
              "icoX": 2,
              "extId": "740046148",
              "crd": {
                "x": 18115979,
                "y": 59314216
              },
              "pCls": 128
            },
            {
              "lid": "A=1@O=Henriksdalsberget (Nacka kn)@X=18117219@Y=59311169@U=80@L=740046149@",
              "type": "S",
              "name": "Henriksdalsberget (Nacka kn)",
              "icoX": 2,
              "extId": "740046149",
              "crd": {
                "x": 18117219,
                "y": 59311169
              },
              "pCls": 128
            }
          ],
          "prodL": [
            {
              "name": "Länstrafik - Buss 53",
              "number": "53",
              "line": "53",
              "icoX": 1,
              "cls": 128,
              "oprX": 0,
              "prodCtx": {
                "name": "BLT   53",
                "num": "72413",
                "line": "53",
                "catOut": "BLT     ",
                "catOutS": "BLT",
                "catOutL": "Länstrafik - Buss",
                "catIn": "BLT",
                "catCode": "7"
              }
            }
          ],
          "opL": [
            {
              "name": "SL",
              "url": "http://www.sl.se",
              "icoX": 0
            }
          ],
          "remL": [],
          "icoL": [
            {
              "res": "275",
              "txt": "SL"
            },
            {
              "res": "PCL7",
              "txt": "53"
            },
            {
              "res": "STA"
            }
          ]
        },
        "journey": {
          "jid": "1|132637|1|80|5032017",
          "date": "20170305",
          "prodX": 0,
          "dirTxt": "Henriksdalsberget (Nacka kn)",
          "dirFlg": "1",
          "status": "P",
          "isRchbl": true,
          "stopL": [
            {
              "locX": 0,
              "idx": 0,
              "dProdX": 0,
              "dTimeS": "152700",
              "dProgType": "PROGNOSED",
              "isImp": true
            },
            {
              "locX": 1,
              "idx": 1,
              "aProdX": 0,
              "aTimeS": "153000",
              "dProdX": 0,
              "dTimeS": "153000",
              "isImp": true
            },
            {
              "locX": 2,
              "idx": 2,
              "aProdX": 0,
              "aTimeS": "153100",
              "dProdX": 0,
              "dTimeS": "153100",
              "isImp": true
            },
            {
              "locX": 3,
              "idx": 3,
              "aProdX": 0,
              "aTimeS": "153200",
              "dProdX": 0,
              "dTimeS": "153200",
              "isImp": true
            },
            {
              "locX": 4,
              "idx": 4,
              "aProdX": 0,
              "aTimeS": "153300",
              "dProdX": 0,
              "dTimeS": "153300",
              "isImp": true
            },
            {
              "locX": 5,
              "idx": 5,
              "aProdX": 0,
              "aTimeS": "153400",
              "dProdX": 0,
              "dTimeS": "153400"
            },
            {
              "locX": 6,
              "idx": 6,
              "aProdX": 0,
              "aTimeS": "153700",
              "dProdX": 0,
              "dTimeS": "153700"
            },
            {
              "locX": 7,
              "idx": 7,
              "aProdX": 0,
              "aTimeS": "153700",
              "dProdX": 0,
              "dTimeS": "153700"
            },
            {
              "locX": 8,
              "idx": 8,
              "aProdX": 0,
              "aTimeS": "153900",
              "dProdX": 0,
              "dTimeS": "153900"
            },
            {
              "locX": 9,
              "idx": 9,
              "aProdX": 0,
              "aTimeS": "154000",
              "dProdX": 0,
              "dTimeS": "154000"
            },
            {
              "locX": 10,
              "idx": 10,
              "aProdX": 0,
              "aTimeS": "154200",
              "dProdX": 0,
              "dTimeS": "154200"
            },
            {
              "locX": 11,
              "idx": 11,
              "aProdX": 0,
              "aTimeS": "154500",
              "dProdX": 0,
              "dTimeS": "154500"
            },
            {
              "locX": 12,
              "idx": 12,
              "aProdX": 0,
              "aTimeS": "154700",
              "dProdX": 0,
              "dTimeS": "154700"
            },
            {
              "locX": 13,
              "idx": 13,
              "aProdX": 0,
              "aTimeS": "155100",
              "dProdX": 0,
              "dTimeS": "155100"
            },
            {
              "locX": 14,
              "idx": 14,
              "aProdX": 0,
              "aTimeS": "155400",
              "dProdX": 0,
              "dTimeS": "155400"
            },
            {
              "locX": 15,
              "idx": 15,
              "aProdX": 0,
              "aTimeS": "155500",
              "dProdX": 0,
              "dTimeS": "155500"
            },
            {
              "locX": 16,
              "idx": 16,
              "aProdX": 0,
              "aTimeS": "155700",
              "dProdX": 0,
              "dTimeS": "155700"
            },
            {
              "locX": 17,
              "idx": 17,
              "aProdX": 0,
              "aTimeS": "155900",
              "dProdX": 0,
              "dTimeS": "155900"
            },
            {
              "locX": 18,
              "idx": 18,
              "aProdX": 0,
              "aTimeS": "160000",
              "dProdX": 0,
              "dTimeS": "160000"
            },
            {
              "locX": 19,
              "idx": 19,
              "aProdX": 0,
              "aTimeS": "160200",
              "dProdX": 0,
              "dTimeS": "160200"
            },
            {
              "locX": 20,
              "idx": 20,
              "aProdX": 0,
              "aTimeS": "160300",
              "dProdX": 0,
              "dTimeS": "160300"
            },
            {
              "locX": 21,
              "idx": 21,
              "aProdX": 0,
              "aTimeS": "160400",
              "dProdX": 0,
              "dTimeS": "160400"
            },
            {
              "locX": 22,
              "idx": 22,
              "aProdX": 0,
              "aTimeS": "160500",
              "dProdX": 0,
              "dTimeS": "160500"
            },
            {
              "locX": 23,
              "idx": 23,
              "aProdX": 0,
              "aTimeS": "160600",
              "dProdX": 0,
              "dTimeS": "160600"
            },
            {
              "locX": 24,
              "idx": 24,
              "aProdX": 0,
              "aTimeS": "161100",
              "aProgType": "PROGNOSED"
            }
          ],
          "sDaysL": [
            {
              "sDaysR": "lör, sön",
              "sDaysI": "och 14., 17. apr, 25. maj, 6. jun",
              "sDaysB": "0C183060C187860C183062C1A306",
              "fLocX": 0,
              "tLocX": 24
            }
          ],
          "poly": {
            "name": "standard",
            "delta": true,
            "dim": 2,
            "type": "WGS84",
            "crdEncYX": "iyciJwo_mB`OsXgNoQpD{d@|Ced@nBqY}C}c@]qOvQsPfJ_OcGyg@bVsd@vWvAxOhLn^_OqBgf@_Buu@vC}i@|CmWnIsm@q@|KgBsN_G_OTe]`RwF",
            "crdEncZ": "",
            "crdEncS": "NNNNNNNNNNNNNNNNNNNNNNNNN",
            "ppLocRefL": [
              {
                "ppIdx": 0,
                "locX": 0
              },
              {
                "ppIdx": 1,
                "locX": 1
              },
              {
                "ppIdx": 2,
                "locX": 2
              },
              {
                "ppIdx": 3,
                "locX": 3
              },
              {
                "ppIdx": 4,
                "locX": 4
              },
              {
                "ppIdx": 5,
                "locX": 5
              },
              {
                "ppIdx": 6,
                "locX": 6
              },
              {
                "ppIdx": 7,
                "locX": 7
              },
              {
                "ppIdx": 8,
                "locX": 8
              },
              {
                "ppIdx": 9,
                "locX": 9
              },
              {
                "ppIdx": 10,
                "locX": 10
              },
              {
                "ppIdx": 11,
                "locX": 11
              },
              {
                "ppIdx": 12,
                "locX": 12
              },
              {
                "ppIdx": 13,
                "locX": 13
              },
              {
                "ppIdx": 14,
                "locX": 14
              },
              {
                "ppIdx": 15,
                "locX": 15
              },
              {
                "ppIdx": 16,
                "locX": 16
              },
              {
                "ppIdx": 17,
                "locX": 17
              },
              {
                "ppIdx": 18,
                "locX": 18
              },
              {
                "ppIdx": 19,
                "locX": 19
              },
              {
                "ppIdx": 20,
                "locX": 20
              },
              {
                "ppIdx": 21,
                "locX": 21
              },
              {
                "ppIdx": 22,
                "locX": 22
              },
              {
                "ppIdx": 23,
                "locX": 23
              },
              {
                "ppIdx": 24,
                "locX": 24
              }
            ]
          }
        },
        "fpB": "20170228",
        "fpE": "20170618"
      },
      "errTxt": ""
    }
  ]
}
 
Wenn ihr so langen code postet dann bitte mit
dem hier ;)

Und für mich sieht es so aus als ob es zu jeder "locL" einen "stopL" Eintrag gibt, richtig? Denn dann kann man doch einfach soetwas machen, z.B. hier in PHP. Kann man sich z.B. dann als HTML Tabelle ausgeben, in eine .html Datei schreiben, oder auch als .txt oder sogar excel tabelle speichern.

PHP:
<?php

// Generated by curl-to-PHP: http://incarnate.github.io/curl-to-php/
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, "http://reseplanerare.resrobot.se/bin/mgate.exe");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"ver\":\"1.10\",\"lang\":\"swe\",\"auth\":{\"type\":\"AID\",\"aid\":\"h5o3n7f4t2m8l9x1\"},\"client\":{\"id\":\"SAMTRAFIKEN\",\"type\":\"WEB\",\"name\":\"Resrobot\",\"v\":\"3.0.0\",\"l\":\"vs_resrobot\"},\"formatted\":false,\"svcReqL\":[{\"meth\":\"JourneyDetails\",\"req\":{\"jid\":\"1|5532|0|80|5032017\"}}],\"ext\":\"SAM.3.0\"}|");
curl_setopt($ch, CURLOPT_POST, 1);

$headers = array();
$headers[] = "Dnt: 1";
$headers[] = "Content-Type: application/x-www-form-urlencoded";
$headers[] = "Referer: http://reseplanerare.resrobot.se/bin/help.exe/sn?L=vs_resrobot&tpl=webapp&";
$headers[] = "Origin: http://reseplanerare.resrobot.se";
$headers[] = "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/602.4.8 (KHTML, like Gecko) Version/10.0.3 Safari/602.4.8";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($ch);
if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
}
curl_close ($ch);


//parsen und beide arrays in variable packen, wird sonst unübersichtlich ;) 
$arr = json_decode($result, true);
$locArr = $arr["svcResL"][0]["res"]["common"]["locL"];
$timeArr = $arr["svcResL"][0]["res"]["journey"]["stopL"];
?>

<html>
  <head>
    <title>Beispielschleife</title>
  </head>
  <body>

    <table>
      <tr><th>Name</th><th>dTimeS</th><th>aTimeS</th></tr>

        <?php
          //loop über locL
          for ($i = 0; $i < count($locArr); $i++) {
            echo '<tr>';
				
            $dTimeS = 0;
            $aTimeS = 0;

            //sicherheitshalber schauen ob es stopL gibt
            if (isset($timeArr[$i])) {

              //falls es den eintrag gibt den wert nutzen
              $dTimeS = (isset($timeArr[$i]["dTimeS"])) ? $timeArr[$i]["dTimeS"] : 0;
              $aTimeS = (isset($timeArr[$i]["aTimeS"])) ? $timeArr[$i]["aTimeS"] : 0;

            }
				
            echo '<td>' . $locArr[$i]["name"] . '</td>';
            echo '<td>' . $dTimeS . '</td>';
            echo '<td>' . $aTimeS . '</td>';

            echo '</tr>';
          }
        ?>

     </table>

  </body>
</html>

Habs mal kurz hochgeladen: http://89.163.210.104/test.php

Edit: Hab halt keine Ahung was die ganzen Einträge bei "stopL" sind, müsstest du halt anpassen. Oder in irgendeiner anderen Sprache umschreiben.

Bzw. kann man das PHP script auch um Eingaben erweitern, und das Ergebniss dann als download bekommen. Dann gibst du nur die jid (oder was auch immer benötigt ist) ein und bekommst direkt die Tabelle. Wenn du das öfters machst wäre so eine Lösung wohl am sinnvollsten ;)
 
Zuletzt bearbeitet:
Ui cool. Super :)
Also das Beispiel sieht genau so aus, wie ich mir es vorgestellt habe. Danke
Ich werde es in der Nacht einmal ausprobieren.
 
Zurück
Oben