When Scraping Website use Jinja as select

I want to scrape this website: https://www.essenbestellung-wildenhain.de/speiseplan/1/ajax/

Therefor, I need to get the current date in this style: 030225 (ddmmyy) as there is an div with ID “collapse030225”. Under this, there are two where I need the second one.

So I tried the following:
#collapse{{now().strftime(‘%d%m%y’)}} > table > tbody > tr > td > span:nth-child(2)”

But this produces an error as I think, jinja is not executed with “scrape:”.
Is that so?

Is there another possibility to get the result of the second span (with ID “child-meal–26048”)

PS: This is a page where I see the lunch meals of my child for the upcoming weeks.
I want to see what is todays meal and the meal tomorrow.

Maybe you have another Idea.

Thanks in advance!

Jinja is supported in the value_template field. So, perform the select of the wrapper element and then parse out what you need.

I tried that too, but when using functions and regex together, I cannot figure something out.

How can I export the red part of the screenshot (where 270125 is 2025-01-27)?

You can target the class instead of the id. Given it looks like you want the first one, “.panel-collapse” gets you there. So

.panel-collapse  > table > tbody > tr > td > span:nth-child(2)

However that seems empty - are you wanting to get the 2nd span, which would be nth-child(1) given it starts at zero?

Not really.
If today ist Monday the 27th of January 2025, then I need the first class (or ID collapse270125).
If today ist Tuesday the 28th of January 2025, then I need the first class (or ID 280125).

This gives me todays Meal in the Kindergarten.
I want to see todays meal (so I need the current ID collapse[dd][mm][yy]) and the meal for tomorrow.
Another hurdle is, that this first div shows only the Meals from Monday to Friday from the first week.

I finally got it and are doing it like this now:

  - resource: https://www.essenbestellung-wildenhain.de/speiseplan/1/ajax/
    scan_interval: 3600
    sensor:
      - name: Mittagessen Montag
        select: "td > span"
        index: 1
        icon: mdi:silverware-fork-knife
        value_template: >
            {{ value | regex_replace(find='((C;[1-5]|[1-9A-N]|10)([\s,]|$),*)*', replace='', ignorecase=False) }}
      - name: Vesper Montag
        select: "td > span"
        index: 3
        icon: mdi:coffee
        value_template: >
            {{ value | regex_replace(find='((C;[1-5]|[1-9A-N]|10)([\s,]|$),*)*', replace='', ignorecase=False) }}

For every meal I increase the index by 2.

Also, I created a binary sensor for every workday and then I show a conditional card with markdown that show the meals of today and tomorrow.