Find nodeList nested <span>

21 views Asked by At

I'm trying to web-scrape for the first time in order to get the best deal out of my holiday.

(My intention is to have a Telegram Bot that everyday checks a specific day in the hotel calendar and sends me a notification)

This calendar that has this specific HTML structure (see pic for reference) html day and what I'm tryng to get is the price of a specific day. So then I can later make something that checks the website daily (8:05 am) and send me a notification.

This also could be a nice project for my portfolio and not only a way to get the best deal as I'm always broke.

This is what my code looks like

document.querySelectorAll('[aria-label="mar 31 ott 2023"]')

to get the specific day and as a result in the logs I get this (see pic) enter image description here

How can I get only the price that has this html structure <span><strong>999€</strong></span> ?

In the console output it is under the innerText. (alongide the day)

I hope I have been enough clear in what I need help with

1

There are 1 answers

0
Artem Ya On

You can try to run querySelector method once again on the node that you need. Something like this

document.querySelectorAll('[aria-label="mar 31 ott 2023"]')[0].querySelector('strong').innerText