Help please with understanding Scrape sensor

Please help with understanding Scrape sensor
try get petrol price data

  - name: gas_provider
    resource: "https://www.motorist.co.th/en/petrol-prices"
    scan_interval: 3600
    sensor:
      - unique_id: gas_provider
        name: "Gas prices"
        value_template: 0.0
        unit_of_measurement: "THB/L"
        icon: mdi:gas-station
        select: "body > main > div > div.container.pb-5.fuel_comparison > div:nth-child(1) > div > div > div > div.th-fuel-table > table > tbody > tr:nth-child(2)"
  • Explain what number you are trying to get from that page.
  • Use View Source (not DevTools) to check the number you want is in the original HTML from the server — it might be fetched separately and dynamically inserted, and scrape can’t help with that.
  • If the number is in the HTML, work out a simpler select — you don’t need the whole chain.
  • A common problem is that DevTools builds a tbody into the DOM chain that isn’t in the HTML — check and adjust as necessary.
1 Like

thanks, but i think chain is good in this code.
in first version of sensor i have get an Unavailable
but now, now i get 0.0 THB/L

multiscrape:
  - name: gas_provider
    resource: "https://www.motorist.co.th/en/petrol-prices"
    scan_interval: 3600
    sensor:
      - unique_id: gas_provider
        name: "Gas prices"
        value_template: 0.0
        unit_of_measurement: "THB/L"
        icon: mdi:gas-station
        select: "body > main > div > div > div:nth-child(1) > div > div > div > div.th-fuel-table > table > tbody > tr:nth-child(2) > td.text-left.th-grade-name"

up…
no help?