Web Scrape (Tormorrow's gas price today)

I had tried to figure out how to get a notification from a web site when an updated status was posted. I then looked more closely at the web scrape integration and after doing a lot of reading and watching many youtube videos I was able to educate myself enough to get this automation to work.

The integration looks at the site https://toronto.citynews.ca/toronto-gta-gas-prices/ and scans it every 30 mins and pulls the data into a sensor that notes the gas price change expected for the next day.

Following the format used by other users I created a separate yaml file called multiscrape.yaml and linked to configuration.yaml like so

multiscrape: !include multiscrape.yaml in configuration.yaml

I put the following into the multiscrape.yaml file.

- resource: https://toronto.citynews.ca/toronto-gta-gas-prices/
  scan_interval: 1800
    - name: Tomorrow Gas Price
      select: ".float-box"
      value_template: '{{ value.split("expected to ")[1].split(" at")[0] }}'

The new sensor sensor.tomorrow_gas_price can then be used to display its info as a entity in HA or push a notification to my phone, I used Node-Red for this mainly because I’m forcing myself to learn new things and Node-Red has been on my list for while.

Typically the website updated this data everyday between 9am and 11am, ideally I wish I knew of way to only limit the scraping during this period instead 48 times a day.

I’m sharing my solution in hopes it helps others find this useful and can avoid the time I spent learning from my errors.