adixus
(Xboxromania)
February 9, 2024, 8:09am
1
Can someone please help me solve a problem I’ve been struggling with for a few days. I use the multiscrape sensor and I want to take the price of a product…and I can’t, I only get “Unavailable”.
- resource: https://epantofi.ro/p/pantofi-nike-air-max-270-ah6789-100-white-black-white/
scan_interval: 600
sensor:
- unique_id: Epantofi
name: Epantofi
select: ".final-price promotional"
value_template: '{{ value.split(" ")[0] | replace (",", ".") | float}}'
unit_of_measurement: "RON"
Troon
(Troon)
February 9, 2024, 8:56am
2
Your select
is looking for an class
of final-price
then an element with a tag name of promotional
, something like:
<div id="final-price"><promotional>790</promotional></div>
The source, though, is:
<div data-test-id="final-price" class="final-price promotional" data-v-3846117a="">
790,00 Lei
</div>
So your select
should be:
select: 'div.final-price.promotional'
However, I cannot get that to work either. Weird things are going on with that page. If I do a “raw” curl
download of it, I don’t get the same HTML source that my browser does. That’s going to need a lot of work to find that value: there is a JSON resource that contains it:
https://epantofi.ro/t-api/rest/search/eobuwie/v5/products?channel=eobuwie¤cy=RON&locale=ro_RO&filters[product_group_associated][in][]=AH6789&select_locales[]=pl_PL&select[]=product_active&select[]=product_badge&select[]=manufacturer&select[]=manufacturer_with_collection&select[]=clothes_size&select[]=main_color&select[]=discount&select[]=eco_friendly&select[]=fason&select[]=final_price&select[]=footwear_size&select[]=tegosc&select[]=hot_deal&select[]=images&select[]=model&select[]=nazwa_wyswietlana&select[]=nazwa_wyswietlana_front&select[]=okazja&select[]=price&select[]=producent&select[]=rozmiar_karta_produktu&select[]=product_group_associated&select[]=series_name&select[]=size_type&select[]=index&select[]=action_label&select[]=akcje_marketingowe&select[]=technologie_entity&select[]=url_key&select[]=video_url&select[]=product_color_variants_count&select[]=omnibus_discount&select[]=omnibus_price&select[]=true_size_female&select[]=true_size_male&select[]=true_size_child&limit=250&with_stocks=1
If you copy/paste that into here and select JSON Viewer, you’ll see the data. You could use a Rest sensor to get that.
adixus
(Xboxromania)
February 9, 2024, 9:43am
3
I would use the rest sensor…if I knew how