How can get scrap these values?

hello i want get these values

from this website: http://www.transporlis.pt/DesktopModules/trp_horarios/Ajax/trp_horario_2.ashx?cmd=getLine&codOp=2&lineId=164&hora=23&min=33&date=25-9-2018

i am trying use :

sensor:
  - platform: scrape
    name: value1
    resource: https://www.home-assistant.io
    select: "_______"
sensor:
  - platform: scrape
    name: value2
    resource: https://www.home-assistant.io
    select: "_______"

but i dont know what i should put on SELECT:

@Mariusthvdb , @Bob_NL any ideas?

Assuming they’re ALWAYS going to be in the same place, you’d need a count of <p> or a count of <td

sensor:
  - platform: scrape
    name: SALDANHA
    resource: http://www.transporlis.pt/DesktopModules/trp_horarios/Ajax/trp_horario_2.ashx?cmd=getLine&codOp=2&lineId=164&hora=23&min=33&date=25-9-2018
    select: 'p:nth-of-type(8)'

  - platform: scrape
    name: ENTRECAMPOS
    resource: http://www.transporlis.pt/DesktopModules/trp_horarios/Ajax/trp_horario_2.ashx?cmd=getLine&codOp=2&lineId=164&hora=23&min=33&date=25-9-2018
    select: 'p:nth-of-type(12)'

You may need to adjust the numbers (8 and 12) if the position is a bit different

1 Like

I’m not sure if you can use this or not but I needed to create a sensor to get the state of motion detection on my cameras.

I ended up using a command line sensor and used ‘curl’ to get the website info and ‘grep’ to split out what info I wanted from it.

Here is the command line portion:

command: 'curl -k --silent "http://192.168.1.52:8002/cgi-bin/CGIProxy.fcgi?cmd=getDevState&usr=xxxx&pwd=yyyy" | grep -oP "(?<=motionDetectAlarm>).*?(?=</motionDetectAlarm>)"'

You could create a sensor for each city using the same website address but change the grep parameters to only read the info between (for example)

"saldanha</a></p></td><td class="description" valign="top"><p>"

and the next

"</p>"

That way it doesn’t matter where it is it just matches on a search string and returns the result of whatever is between them.

1 Like

thanks guys for replys :wink: