Advertisement
Guest User

WebScrap

a guest
Jan 23rd, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. import requests
  2. import json
  3. import jsonp2json
  4.  
  5. jsonp_response = requests.get('http://sonomatech-production.s3.amazonaws.com/sacramento/airquality_org/cbyb-widget/burncheckForecast.txt')
  6.  
  7. json_result = jsonp2json.convert(jsonp_response.text)
  8.  
  9. #print(json_result)
  10. forecast = json.loads(json_result)
  11.  
  12. aqi_today = forecast['burn_forecast']['today']['aqi']
  13. aqi_tomorrow = forecast['burn_forecast']['tomorrow']['aqi']
  14.  
  15. cat_today = forecast['burn_forecast']['today']['category']
  16. cat_tomorrow = forecast['burn_forecast']['tomorrow']['category']
  17.  
  18. if cat_today == 6:
  19. print("All Burning is Allowed Today. The Air Quality Index (AQI) High Today is {}.".format(aqi_today))
  20. elif cat_today == 7:
  21. print("Burning is Discouraged Today. The Air Quality Index (AQI) High Today is {}.".format(aqi_today))
  22. elif cat_today == 8:
  23. print("Stage 1 No Burn Unless Exempt. The Air Quality Index (AQI) High Today is {}.".format(aqi_today))
  24. else:
  25. print("Stage 2 No Burn, All Burning Prohibited. The Air Quality Index (AQI) High Today is {}.".format(aqi_today))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement