Alternatives to the "scrape sensor" for getting information from a website on demand

This is the website:
https://www.metlink.org.nz/stop/7730

The website updates in real time each time you reload the page.
My wife always misses her bus. I want to give her a warning that the bus is about to leave in 5 minutes time.
The scrape sensor polls the website every (?2 minutes), but I only really need to check the website a couple of times just after 8am.
Is there a web scrape component that will scrape on demand, rather than at fixed intervals like the sensor?

what about using node-red

Hmm I had a think about it, and I think I might be ok with the scraper sensor, but I’m a little stuck

Website:
https://www.metlink.org.nz/stop/7730

CSS Selector:
#live-departures > div.rt-info-content > div > table > tbody > tr:nth-child(1) > td:nth-child(3) > span

Instructions:


https://www.crummy.com/software/BeautifulSoup/bs4/doc/#css-selectors

I’m not sure how to code this:

sensor:
  - platform: scrape
    resource: https://www.metlink.org.nz/stop/7730
    select: ??????????????????????????

Here is the node red verson

[{"id":"a78ee365.7134f","type":"inject","z":"b14a9aff.a6c058","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":100,"y":40,"wires":[["465cccbc.e2ca94"]]},{"id":"465cccbc.e2ca94","type":"http request","z":"b14a9aff.a6c058","name":"","method":"GET","ret":"txt","url":"https://www.metlink.org.nz/stop/7730/departures","tls":"","x":170,"y":140,"wires":[["5574f570.4846bc"]]},{"id":"5574f570.4846bc","type":"html","z":"b14a9aff.a6c058","name":"","property":"","outproperty":"","tag":"table[class='table table-condensed table-hover']","ret":"html","as":"multi","x":400,"y":40,"wires":[["50634a7e.dc9394"]]},{"id":"50634a7e.dc9394","type":"html","z":"b14a9aff.a6c058","name":"","property":"","outproperty":"","tag":"td","ret":"text","as":"single","x":330,"y":260,"wires":[["630d7676.6f8fe8","808ddd14.8646a"]]},{"id":"630d7676.6f8fe8","type":"function","z":"b14a9aff.a6c058","name":"","func":"var n0 = msg.payload[2];\nvar n1 = msg.payload[6];\nvar n2 = msg.payload[10];\nvar msg0 = { payload:n0 };\nvar msg1 = { payload:n1 };\nvar msg2 = { payload:n2 };\nreturn [ msg0 , msg1 , msg2];","outputs":3,"noerr":0,"x":390,"y":420,"wires":[["b991b875.789178"],["54612f01.005f5"],["43592e17.f3b77"]]},{"id":"cd17f0fe.53028","type":"debug","z":"b14a9aff.a6c058","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":710,"y":220,"wires":[]},{"id":"b991b875.789178","type":"function","z":"b14a9aff.a6c058","name":"","func":"node.status({fill:\"green\",shape:\"ring\",text:msg.payload});\nreturn msg;","outputs":1,"noerr":0,"x":550,"y":340,"wires":[["cd17f0fe.53028","52b08262.b7f8ec"]]},{"id":"54612f01.005f5","type":"function","z":"b14a9aff.a6c058","name":"","func":"node.status({fill:\"green\",shape:\"ring\",text:msg.payload});\nreturn msg;","outputs":1,"noerr":0,"x":550,"y":400,"wires":[["858af62a.d18298"]]},{"id":"808ddd14.8646a","type":"debug","z":"b14a9aff.a6c058","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":510,"y":200,"wires":[]},{"id":"43592e17.f3b77","type":"function","z":"b14a9aff.a6c058","name":"","func":"node.status({fill:\"green\",shape:\"ring\",text:msg.payload});\nreturn msg;","outputs":1,"noerr":0,"x":550,"y":460,"wires":[["ceb15bdb.3f9bb8"]]},{"id":"52b08262.b7f8ec","type":"mqtt out","z":"b14a9aff.a6c058","name":"","topic":"home/bus1","qos":"","retain":"","broker":"987c4047.b2d81","x":730,"y":340,"wires":[]},{"id":"858af62a.d18298","type":"mqtt out","z":"b14a9aff.a6c058","name":"","topic":"home/bus2","qos":"","retain":"","broker":"987c4047.b2d81","x":730,"y":400,"wires":[]},{"id":"ceb15bdb.3f9bb8","type":"mqtt out","z":"b14a9aff.a6c058","name":"","topic":"home/bus3","qos":"","retain":"","broker":"987c4047.b2d81","x":730,"y":460,"wires":[]},{"id":"987c4047.b2d81","type":"mqtt-broker","z":"","name":"","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","willTopic":"","willQos":"0","willPayload":""}]

It just read the next 3 and post them to mqtt

you can set the timestamp to repeat every what ever you want

2 Likes

thanks guess I might be finally getting around to adding nodered to hassio.

go for it im from NP bell block

what is “NP bell block”

https://www.metlink.org.nz/stop/7730/departures

^ I like. thanks.

That was the hard bit to find took about hour to find that

New plymouth Bell block

Christchurch.

next you do node-red the rubbish collection LOL

I have well still getting the bugs out of it NP website not the best for scraping