Help scrape sensor and multiscrape sensor

hi. i need some help to use scrape sensor to pull up the prices of the fuel of this page:


i want to extract the price of Gasolina 95 Simples , price of Gasolina 95 + and so on (the 5 prices)

i have done inspect on top of price that i want : and then copy and copy selecter
it gives this:
#station > div.box.main > div.precos > div:nth-child(1) > div.valor > div
and mark the price on the webpage.
but the proble is when i put on homeassistant , nothing shows
if i test on css selector text (extension of chrome) it works !


i have try on scrape plataform and in on multiscrape plataform too, and didn’t work (i don’t have any error on logs file) but the variavel shows empty no HA

my code on home assistant: configuration.yaml

- platform: scrape  #sensor para ir buscar preço combustivel site mais gasolina:
    name: gasol95 #preço_gasolina_95_repsol_vainhos_cresche
    resource: https://www.maisgasolina.com/posto/2231/
    #select: "6wMTIxLjYzOQ=="
    #select: "div.encoded"
    #select: "div.preco"
    #select: "#station>div.box.main>div.precos>div:nth-child(1)>div.valor>div"
    select: "div:nth-child(1)>div.valor"
    headers:
      User-Agent: Mozilla/5.0

- platform: multiscrape
    name: home assistant scraper
    resource: https://www.maisgasolina.com/posto/2231/
    #scan_interval: 30
    selectors:
      version:
        name: gasolprecomul
        select: '#station > div.box.main > div.precos > div:nth-child(1) > div.valor > div'
        #value_template: '{{ (value.split(":")[1]) }}'
      releasedate:
        name: gasolprecomul2
        select: "div:nth-child(2)>div.valor"
    headers:
      User-Agent: Mozilla/5.0

can anyone help me ? please. i don’t know what more to do

thanks :wink:

Hi, I read your code because I’m also trying out the multi scrape sensor. I’m not a programmer at all, I’m learning.

I notice that you use single en double quotes in your select. Why?

select: ‘#station > div.box.main > div.precos > div:nth-child(1) > div.valor > div’

vs

    select: "div:nth-child(2)>div.valor"

In the second select, there is no space inbetween the “greater” symbol

I checked the select and the value is shown. Maybe, you have to convert the data type (from string to an integer) if you want to calculate with it.

1 Like