Scrape Sensor - Problem with class

I am trying to get out values from a webpage with scrape sensor.
I would like to use the class for search but it seems like it always pick the first occurrence of the class when I would like the second.

I cant seem to use nth_of_type together with a class so how should I do?

- platform: scrape
  name: Lunch
  resource: https://mpi.mashie.com/public/app/K%C3%A4vlinge%20kommun/Stinsg%C3%A5rdenfsk
  select: '.app-daymenu-name'

“.list-group-item:nth-of-type(2) .app-daymenu-name”

Does that work?

unfortunately not. still gets

  File "/usr/lib/python3.6/site-packages/homeassistant/components/sensor/scrape.py", line 120, in update
    value = raw_data.select(self._select)[0].text
IndexError: list index out of range

The selected text on thr below url is what I want.
image

https://mpi.mashie.com/public/app/Kävlinge%20kommun/Stinsgårdenfsk

Can you post your scrape sensor config again?

Here is the final, working scrape.
Got some help in another forum

select: ‘.panel > div:nth-of-type(2) > div:nth-of-type(1) .app-daymenu-name’

Just for the record… :hamburger::fries:

If someone else wish to import mashie here are some findings:

Find the menu in mashie, but alter the URL

Instead of app:
https://mpi.mashie.com/public/app/Kävlinge%20kommun/Stinsgårdenfsk

Use menu:
https://mpi.mashie.com/public/menu/Kävlinge%20kommun/Stinsgårdenfsk

Or menu with querystring old=True
https://mpi.mashie.com/public/menu/Kävlinge%20kommun/Stinsgårdenfsk?old=True

With menu, you can easily integrate with iframe in lovelace:

Or maybe it offers other possibilities when scraping?

This is a nice find as well if you get stuck with scraping sites:

1 Like