Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 1320

Python • Re: open meteo - extract sunrise time

$
0
0
This example uses curl to get the data (I did not want to install any new modules) from open-meteo. Then we convert the string result to JSON and extract sunrise time to get

Code:

02:5202:5102:5002:4902:4802:4802:47

Code:

import subprocessimport jsonurlll = "https://api.open-meteo.com/v1/forecast?latitude=52.52&longitude=13.41"params = "&daily=sunrise"myurl = urlll+paramsresult=subprocess.run(["curl", "-X", "GET", myurl], capture_output=True, text=True)jresult=json.loads(result.stdout)i=0while i<7:  mytime =jresult['daily']['sunrise'][i]  myhhmm = mytime.split("T",1)[1]  print (myhhmm)  i=i+1

Statistics: Posted by neilgl — Tue May 28, 2024 2:38 pm



Viewing all articles
Browse latest Browse all 1320

Trending Articles