Setting Scrape Sensor parameters from working BeautifulSoup

I am trying to scrape the total precipitation from this web site.

I got it working with a python script below but can’t find the correct paraments for the scrape sensor.

Any suggestions are appreciated.

import requests
from bs4 import BeautifulSoup
page = requests.get('https://weather.gc.ca/city/pages/bc-74_metric_e.html')
soup = BeautifulSoup(page.text, 'html.parser')
mm = soup.find_all(class_='wxo-metric-hide')[141].get_text()
print (mm);

This doesn’t work

################################################
  - platform: scrape
    name: Rainfall
    resource: https://weather.gc.ca/city/pages/bc-74_metric_e.html
    select: 'wxo-metric-hide'
    index: 141
##########################################

I figured it out.

  - platform: scrape
    name: Rainfall
    resource: https://weather.gc.ca/city/pages/bc-74_metric_e.html
    select: '[class~=wxo-metric-hide]'
    index: 141
    value_template: "{{ value.split(' ')[1] | int }}"
    unit_of_measurement: 'mm'
1 Like