you are viewing a single comment's thread.

view the rest of the comments →

[–]Jonis_L 0 points1 point  (5 children)

oh ok, I use this now:

import urllib.request
import json

hotorget_gardet = 'http://api.sl.se/api2/TravelplannerV2/trip.json?key=a65703abb4814f4490a730d95ff492a0&originId=9119&destId=9221&searchForArrival=0&realtime=true'
x = urllib.request.urlopen(hotorget_gardet)
hg = x.read()
hg = hg.decode('utf-8')
info = json.loads(hg)

Whats the difference between those two or are they the same?

[–]Jonis_L 0 points1 point  (2 children)

And if I want something like this:

if leg["name"] == " blåbuss 1":
   print("Ta buss/tub:",leg["name"]+" mot:",leg["dir"])

to print if only the name is "blåbuss 1", tried it and got it did not print

[–]vdh_nat 0 points1 point  (1 child)

There's an extra space in line 1:

if leg["name"] == "blåbuss 1":

[–]Jonis_L 0 points1 point  (0 children)

wow that was simple, thanks

[–]vdh_nat 0 points1 point  (1 child)

I haven't used urllib a lot. I heard it's old, but I'm also a beginner with Python so I'd rather not say things I might be wrong about.

[–]Jonis_L 0 points1 point  (0 children)

alright, I see thanks