Hi,
Da es aktuell interessant ist für alle PV Besitzer, hab ich mal versucht den Tages Strompreis von der Website zu scrapen.
Diesen hätte ich nun auch gerne in ein Item geschrieben aber ich denke ich muss da noch etwas importieren um auf 'sh.' zugreifen zu können.
Kann mir bitte jemand den nötigen Input geben?
Danke schon mal.
/Markus
Da es aktuell interessant ist für alle PV Besitzer, hab ich mal versucht den Tages Strompreis von der Website zu scrapen.
Code:
#!/usr/bin/env python # #!/usr/bin/env python # from datetime import date, timedelta import requests from bs4 import BeautifulSoup today = date.today() Tomorrow = date.today() + timedelta(days=1) #URL = 'https://www.epexspot.com/en/market-data?market_area=AT&trading_date=2022-09-06&delivery_date=2022-09-07&underlying_year=&modality=Auction&sub_modality=DayAhead&product=60&data_mode=table&period=' URL_1 = 'https://www.epexspot.com/en/market-data?market_area=AT&trading_date=' Date_1 = str(today) URL_2 = '&delivery_date=' Date_2 = str(Tomorrow) URL_3 = '&underlying_year=&modality=Auction&sub_modality=DayAhead&product=60&data_mode=table&period=' URL = URL_1 + Date_1 + URL_2 + Date_2 + URL_3 response = requests.get(URL) soup = BeautifulSoup(response.text, 'html.parser') daily_price = soup.find('div', {'class': 'flex day-1'}) daily_price = daily_price.text daily_price = daily_price.replace("\n", "") #print(daily_price) sh.Strom.MarktpreisTag(daily_price)
Code:
Traceback (most recent call last): File "/usr/local/smarthome/logics/StromPreis.py", line 15, in <module> sh.Strom.MarktpreisTag(daily_price) NameError: name 'sh' is not defined
Danke schon mal.
/Markus
Kommentar