Advertisement
jarekmor

radiation_to_json

Jan 21st, 2023
1,016
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.92 KB | None | 0 0
  1. #!/usr/bin/python3
  2.  
  3. import requests
  4. import json
  5. from os.path import exists
  6. from datetime import datetime, timedelta
  7. import time
  8.  
  9. current_time = time.strftime("%Y-%m-%dT%H:%M:%S")
  10. date = datetime.strptime(current_time, "%Y-%m-%dT%H:%M:%S")
  11. now = date.isoformat()
  12.  
  13. url = "https://monitoring.paa.gov.pl/geoserver/ows"
  14. querystring = {"service":"WFS",
  15.                 "version":"2.0.0",
  16.                 "request":"GetFeature",
  17.                 "typeNames":"paa:kcad_siec_pms_moc_dawki_mapa",
  18.                 "outputFormat":"application/json",
  19.                 "viewparams":f"date_from:2023-01-01T17:25:18.000Z;date_to:{now}"}
  20.  
  21. headers = {"Content-Type": "application/json"}
  22.  
  23. response = requests.request("GET", url, headers=headers, params=querystring)
  24. response_json = response.json()
  25. json_object = json.dumps(response_json)
  26.  
  27. with open("/share/htdocs/radiation_test.json", "w") as outfile:
  28.     outfile.write(json_object)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement