could you please give me a hint how to define the scrape function to achieve this?
i tried it with a couple of html tags. with td it shows at least the name of the first lake, when trying tbody the entity is no longer there to integrate in lovelace.
when i tried to apply this procedure on other sites, unfortunately i was not able to scrape the data although the fields where properly identified when choosing inspect element.
i also could not load the values. see corresponding screenshots 1-3.
could you imagine was the problem is and could you tell me, when the above procedure works and when not? i tried this now on a couple sites, it works perfectly on the one mentioned above but does not others.
Hi folks. Can someone please help me get the KP-index from this site? I’ve tried and tried, but I can’t get my head around the formula. If it’s at all possible, that is. I would really appreciate it, thank you! https://www.spaceweatherlive.com/en/auroral-activity.html
Really cool - thanks for your detailed explanation! I am now tracking the water level of my river nearby
I am also interested in getting the current gas level for Europe from this site: https://agsi.gie.eu/
I have copied the sector path as you described, but the sensor in Home Assistant stays unknown
This scrape method will not work. All of the data on that webpage is generated by javascript calling API. Check for page source to see if the data is actually there. So conventional ‘scrape’ will not work here. I did look at that page and found an API call. BUT that call without headers was not working well. Seems like API needed exact headers to work. With headers it was returning a JSON output that we still need to parse so this works for me:
sensor:
#Aggregated Gas Storage Inventory in the EU
- platform: rest
name: AGSI EU Gas Storage Full
value_template: "{{ value_json['data'][0]['full'] }}"
unit_of_measurement: "%"
scan_interval: 3600
resource: https://agsi.gie.eu/api?date=today
headers:
Content-Type: application/json
User-Agent: 'Mozilla/5.0 (iPad; CPU OS 15_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/104.0.5112.99 Mobile/15E148 Safari/604.1'
Upgrade-Insecure-Requests: 1
Referer: 'https://agsi.gie.eu/'
Also a command line sensor can be built from this python script
import requests; import json;
headers = {
'Upgrade-Insecure-Requests': '1',
'User-Agent': 'Mozilla/5.0 (iPad; CPU OS 15_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/104.0.5112.99 Mobile/15E148 Safari/604.1',
'referer': 'https://agsi.gie.eu/'
};
resp = requests.get('https://agsi.gie.eu/api?date=today', headers=headers);
data = json.loads(resp.content);
print(data['data'][0]['full']);
Just in case someone will run into this thread: my solution does not require API registration. It mimics a website visit and therefore no need for an API key.