I want to show next bus departures from my location.
Next 3 departures and time for departure would be great.
Here is the link to bus information:
Bus departures
Is there a way I can scrape this information and show if in HA?
I want to show next bus departures from my location.
Next 3 departures and time for departure would be great.
Here is the link to bus information:
Bus departures
Is there a way I can scrape this information and show if in HA?
Thank you! Just wish I had the knowledge to do this
Ask the bus company where their API is.
In fairness, I think the api (if such even exists) would be just as much work as scraping the site.
@borgeolsen, notice when you select the bus route it gives you a nice long url in the browser which basically contains the request you want, then you use that url in your scrape sensor to return the time fields. So from a random click on the page I got the url…
So I’m guessing that dep1=1&from=Kleiva+(Harstad)&direction=1&
is all just saying an outgoing bus from that stop, date/time/now are telling it when to pick from the timetable, the destination and a few other options to tweak the results.
Once you get the url that reliably outputs the data you want, click view-source on your browser and find what tags the data you want is in, and hopefully we can configure the scrape sensor to pluck it out.
I have found that this is the url gives me exactly what I need:
The original url was much longer, coming from their website tromskortet.no.
About finding tags, I am not sure how to do that. This is what I found when inspecting the data:
So yeah, all the times appear in the tags
<span class="tm-block-float tm-departurelist-time">
17:11
</span>
The problem now is working out how to convey that to the scrape sensor - I can try and have a play with it later this evening - or maybe @fabaff can give us a clue?
Thank you so much
This is ugly AF… but it works
- platform: command_line
name: "Buss Kleiva (Harstad) -> Harstad Byterminal"
command: "curl -sSL 'https://rp.tromskortet.no/scripts/TravelMagic/TravelMagicWE.dll/svar?dep1=1&from=19031302%3A1&direction=1&now=1&destinations=Harstad+Byterminal&changepenalty=1&changepause=0&through=&throughpause=&lang=no' | grep ' ' | sed -n '58p' | awk -F' ' '{ print $1 }'"
Wow. This is a good start
Agreed, maybe not the best presentation. But it looks like this can be done.
My hope is that it would be possible to present it in a nice box, with all the information lined up nicely
Was not the “box” I ment but the way I got the data
God job making that work anyway
Would be better to get a component working for entur’s API that would cover all of norway but I have no idea how to do that
Is there a published api?
My Norwegian is non existent, but no doubt someone should be able to work with it.
I have tried but it was too complex for the end user to use
Accoring to @Danielhiversen Entur is integrated:
https://github.com/home-assistant/home-assistant/pull/17286
Having said that I can’t find this component in HA (Platform not found: sensor.entur_public_transport) so I guess the component didn’t make it to the the 0.83.1 update.
That component was only merged in to the dev branch 7 hours ago, will take a little bit of time to be available in homeassistant, at the very least you’ll have to wait for the next release
You have to use the dev branch or wait for 0.84