Created
May 12, 2022 01:29
-
-
Save KenoLeon/88aad960129b310bf7795e30e419cc72 to your computer and use it in GitHub Desktop.
parse JSON API call static 01
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # AccuEeather API call example 5 Day Forecast for | |
| # Mexico City Code: 242560 | |
| response = {'Headline': {'EffectiveDate': '2022-05-14T08:00:00-05:00', 'EffectiveEpochDate': 1652533200, 'Severity': 4, 'Text': 'Pleasant this weekend', 'Category': 'mild', 'EndDate': None, 'EndEpochDate': None, 'MobileLink': 'http://www.accuweather.com/en/mx/mexico-city/242560/daily-weather-forecast/242560?lang=en-us', 'Link': 'http://www.accuweather.com/en/mx/mexico-city/242560/daily-weather-forecast/242560?lang=en-us'}, 'DailyForecasts': [{'Date': '2022-05-11T07:00:00-05:00', 'EpochDate': 1652270400, 'Temperature': {'Minimum': {'Value': 54.0, 'Unit': 'F', 'UnitType': 18}, 'Maximum': {'Value': 79.0, 'Unit': 'F', 'UnitType': 18}}, 'Day': {'Icon': 3, 'IconPhrase': 'Partly sunny', 'HasPrecipitation': False}, 'Night': {'Icon': 33, 'IconPhrase': 'Clear', 'HasPrecipitation': False}, 'Sources': ['AccuWeather'], 'MobileLink': 'http://www.accuweather.com/en/mx/mexico-city/242560/daily-weather-forecast/242560?day=1&lang=en-us', 'Link': 'http://www.accuweather.com/en/mx/mexico-city/242560/daily-weather-forecast/242560?day=1&lang=en-us'}, {'Date': '2022-05-12T07:00:00-05:00', 'EpochDate': 1652356800, 'Temperature': {'Minimum': {'Value': 52.0, 'Unit': 'F', 'UnitType': 18}, 'Maximum': {'Value': 84.0, 'Unit': 'F', 'UnitType': 18}}, 'Day': {'Icon': 1, 'IconPhrase': 'Sunny', 'HasPrecipitation': False}, 'Night': {'Icon': 34, 'IconPhrase': 'Mostly clear', 'HasPrecipitation': False}, 'Sources': ['AccuWeather'], 'MobileLink': 'http://www.accuweather.com/en/mx/mexico-city/242560/daily-weather-forecast/242560?day=2&lang=en-us', 'Link': 'http://www.accuweather.com/en/mx/mexico-city/242560/daily-weather-forecast/242560?day=2&lang=en-us'}, {'Date': '2022-05-13T07:00:00-05:00', 'EpochDate': 1652443200, 'Temperature': {'Minimum': { | |
| 'Value': 54.0, 'Unit': 'F', 'UnitType': 18}, 'Maximum': {'Value': 85.0, 'Unit': 'F', 'UnitType': 18}}, 'Day': {'Icon': 4, 'IconPhrase': 'Intermittent clouds', 'HasPrecipitation': False}, 'Night': {'Icon': 35, 'IconPhrase': 'Partly cloudy', 'HasPrecipitation': False}, 'Sources': ['AccuWeather'], 'MobileLink': 'http://www.accuweather.com/en/mx/mexico-city/242560/daily-weather-forecast/242560?day=3&lang=en-us', 'Link': 'http://www.accuweather.com/en/mx/mexico-city/242560/daily-weather-forecast/242560?day=3&lang=en-us'}, {'Date': '2022-05-14T07:00:00-05:00', 'EpochDate': 1652529600, 'Temperature': {'Minimum': {'Value': 54.0, 'Unit': 'F', 'UnitType': 18}, 'Maximum': {'Value': 87.0, 'Unit': 'F', 'UnitType': 18}}, 'Day': {'Icon': 2, 'IconPhrase': 'Mostly sunny', 'HasPrecipitation': False}, 'Night': {'Icon': 35, 'IconPhrase': 'Partly cloudy', 'HasPrecipitation': False}, 'Sources': ['AccuWeather'], 'MobileLink': 'http://www.accuweather.com/en/mx/mexico-city/242560/daily-weather-forecast/242560?day=4&lang=en-us', 'Link': 'http://www.accuweather.com/en/mx/mexico-city/242560/daily-weather-forecast/242560?day=4&lang=en-us'}, {'Date': '2022-05-15T07:00:00-05:00', 'EpochDate': 1652616000, 'Temperature': {'Minimum': {'Value': 53.0, 'Unit': 'F', 'UnitType': 18}, 'Maximum': {'Value': 87.0, 'Unit': 'F', 'UnitType': 18}}, 'Day': {'Icon': 2, 'IconPhrase': 'Mostly sunny', 'HasPrecipitation': False}, 'Night': {'Icon': 35, 'IconPhrase': 'Partly cloudy', 'HasPrecipitation': False}, 'Sources': ['AccuWeather'], 'MobileLink': 'http://www.accuweather.com/en/mx/mexico-city/242560/daily-weather-forecast/242560?day=5&lang=en-us', 'Link': 'http://www.accuweather.com/en/mx/mexico-city/242560/daily-weather-forecast/242560?day=5&lang=en-us'}]} | |
| # pretty print response | |
| import json | |
| print(json.dumps(response, indent=4, sort_keys=True)) | |
| # "DailyForecasts": [ | |
| # { | |
| # "Date": "2022-05-11T07:00:00-05:00", | |
| # "Day": { | |
| # "HasPrecipitation": false, | |
| # "Icon": 3, | |
| # "IconPhrase": "Partly sunny" | |
| # }, | |
| # "EpochDate": 1652270400, | |
| # "Link": "http://www.accuweather.com/en/mx/mexico-city/242560/daily-weather-forecast/242560?day=1&lang=en-us", | |
| # "MobileLink": "http://www.accuweather.com/en/mx/mexico-city/242560/daily-weather-forecast/242560?day=1&lang=en-us", | |
| # "Night": { | |
| # "HasPrecipitation": false, | |
| # "Icon": 33, | |
| # "IconPhrase": "Clear" | |
| # }, | |
| # "Sources": [ | |
| # "AccuWeather" | |
| # ], | |
| # "Temperature": { | |
| # "Maximum": { | |
| # "Unit": "F", | |
| # "UnitType": 18, | |
| # "Value": 79.0 | |
| # }, | |
| # "Minimum": { | |
| # "Unit": "F", | |
| # "UnitType": 18, | |
| # "Value": 54.0 | |
| # } | |
| # } | |
| # }, | |
| # { | |
| # "Date": "2022-05-12T07:00:00-05:00", | |
| # "Day": { | |
| # "HasPrecipitation": false, | |
| # "Icon": 1, | |
| # "IconPhrase": "Sunny" | |
| # }, | |
| # "EpochDate": 1652356800, | |
| # "Link": "http://www.accuweather.com/en/mx/mexico-city/242560/daily-weather-forecast/242560?day=2&lang=en-us", | |
| # "MobileLink": "http://www.accuweather.com/en/mx/mexico-city/242560/daily-weather-forecast/242560?day=2&lang=en-us", | |
| # "Night": { | |
| # "HasPrecipitation": false, | |
| # "Icon": 34, | |
| # "IconPhrase": "Mostly clear" | |
| # }, | |
| # "Sources": [ | |
| # "AccuWeather" | |
| # ], | |
| # "Temperature": { | |
| # "Maximum": { | |
| # "Unit": "F", | |
| # "UnitType": 18, | |
| # "Value": 84.0 | |
| # }, | |
| # "Minimum": { | |
| # "Unit": "F", | |
| # "UnitType": 18, | |
| # "Value": 52.0 | |
| # } | |
| # } | |
| # }, | |
| # { | |
| # "Date": "2022-05-13T07:00:00-05:00", | |
| # "Day": { | |
| # "HasPrecipitation": false, | |
| # "Icon": 4, | |
| # "IconPhrase": "Intermittent clouds" | |
| # }, | |
| # "EpochDate": 1652443200, | |
| # "Link": "http://www.accuweather.com/en/mx/mexico-city/242560/daily-weather-forecast/242560?day=3&lang=en-us", | |
| # "MobileLink": "http://www.accuweather.com/en/mx/mexico-city/242560/daily-weather-forecast/242560?day=3&lang=en-us", | |
| # "Night": { | |
| # "HasPrecipitation": false, | |
| # "Icon": 35, | |
| # "IconPhrase": "Partly cloudy" | |
| # }, | |
| # "Sources": [ | |
| # "AccuWeather" | |
| # ], | |
| # "Temperature": { | |
| # "Maximum": { | |
| # "Unit": "F", | |
| # "UnitType": 18, | |
| # "Value": 85.0 | |
| # }, | |
| # "Minimum": { | |
| # "Unit": "F", | |
| # "UnitType": 18, | |
| # "Value": 54.0 | |
| # } | |
| # } | |
| # }, | |
| # { | |
| # "Date": "2022-05-14T07:00:00-05:00", | |
| # "Day": { | |
| # "HasPrecipitation": false, | |
| # "Icon": 2, | |
| # "IconPhrase": "Mostly sunny" | |
| # }, | |
| # "EpochDate": 1652529600, | |
| # "Link": "http://www.accuweather.com/en/mx/mexico-city/242560/daily-weather-forecast/242560?day=4&lang=en-us", | |
| # "MobileLink": "http://www.accuweather.com/en/mx/mexico-city/242560/daily-weather-forecast/242560?day=4&lang=en-us", | |
| # "Night": { | |
| # "HasPrecipitation": false, | |
| # "Icon": 35, | |
| # "IconPhrase": "Partly cloudy" | |
| # }, | |
| # "Sources": [ | |
| # "AccuWeather" | |
| # ], | |
| # "Temperature": { | |
| # "Maximum": { | |
| # "Unit": "F", | |
| # "UnitType": 18, | |
| # "Value": 87.0 | |
| # }, | |
| # "Minimum": { | |
| # "Unit": "F", | |
| # "UnitType": 18, | |
| # "Value": 54.0 | |
| # } | |
| # } | |
| # }, | |
| # { | |
| # "Date": "2022-05-15T07:00:00-05:00", | |
| # "Day": { | |
| # "HasPrecipitation": false, | |
| # "Icon": 2, | |
| # "IconPhrase": "Mostly sunny" | |
| # }, | |
| # "EpochDate": 1652616000, | |
| # "Link": "http://www.accuweather.com/en/mx/mexico-city/242560/daily-weather-forecast/242560?day=5&lang=en-us", | |
| # "MobileLink": "http://www.accuweather.com/en/mx/mexico-city/242560/daily-weather-forecast/242560?day=5&lang=en-us", | |
| # "Night": { | |
| # "HasPrecipitation": false, | |
| # "Icon": 35, | |
| # "IconPhrase": "Partly cloudy" | |
| # }, | |
| # "Sources": [ | |
| # "AccuWeather" | |
| # ], | |
| # "Temperature": { | |
| # "Maximum": { | |
| # "Unit": "F", | |
| # "UnitType": 18, | |
| # "Value": 87.0 | |
| # }, | |
| # "Minimum": { | |
| # "Unit": "F", | |
| # "UnitType": 18, | |
| # "Value": 53.0 | |
| # } | |
| # } | |
| # } | |
| # ], | |
| # "Headline": { | |
| # "Category": "mild", | |
| # "EffectiveDate": "2022-05-14T08:00:00-05:00", | |
| # "EffectiveEpochDate": 1652533200, | |
| # "EndDate": null, | |
| # "EndEpochDate": null, | |
| # "Link": "http://www.accuweather.com/en/mx/mexico-city/242560/daily-weather-forecast/242560?lang=en-us", | |
| # "MobileLink": "http://www.accuweather.com/en/mx/mexico-city/242560/daily-weather-forecast/242560?lang=en-us", | |
| # "Severity": 4, | |
| # "Text": "Pleasant this weekend" | |
| # } | |
| # } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment