#!/usr/bin/python3 import requests import json from os.path import exists from datetime import datetime, timedelta import time current_time = time.strftime("%Y-%m-%dT%H:%M:%S") date = datetime.strptime(current_time, "%Y-%m-%dT%H:%M:%S") now = date.isoformat() url = "https://monitoring.paa.gov.pl/geoserver/ows" querystring = {"service":"WFS", "version":"2.0.0", "request":"GetFeature", "typeNames":"paa:kcad_siec_pms_moc_dawki_mapa", "outputFormat":"application/json", "viewparams":f"date_from:2023-01-01T17:25:18.000Z;date_to:{now}"} headers = {"Content-Type": "application/json"} response = requests.request("GET", url, headers=headers, params=querystring) response_json = response.json() json_object = json.dumps(response_json) with open("/share/htdocs/radiation_test.json", "w") as outfile: outfile.write(json_object)