Line: 1 to 1 | ||||||||
---|---|---|---|---|---|---|---|---|
The weather appIntroduction | ||||||||
Line: 32 to 29 | ||||||||
This shows that the nearest city for which I can get a woeid is Zürich with the id:784794 | ||||||||
Changed: | ||||||||
< < | Sending the request: | |||||||
> > | Sending the request,using the method reponse = urequests.get(url) with the url below | |||||||
https://www.metaweather.com/api/location/784794/ returns a json string of this type, from which you can pick the information of interest to you:
| ||||||||
Changed: | ||||||||
< < | If you inspect the string closely, you can see that weather here is very bad at the moment. | |||||||
> > | response.status_code gives you the http return code (should be 200 if successful). data = response.json() gets the json data for you and converts it into a Python dictionary from which you must extract the information relevant to you. I pick up this information and put it into a friendly GUI:
If you compare this with the json string, you should find back the information. Only the wind speed is different because I convert the units from mph to kph. | |||||||
openweathermap.orgThe basic way for getting weather data from openweathermap.org is the same as described above. However the url string is different following a different API. On openweathermap.org you don't need the woeid, but you can use a city name or the GPS data directly. On the other hand you need an extra apikey, which you get with your registration. | ||||||||
Line: 53 to 53 | ||||||||
| ||||||||
Added: | ||||||||
> > |
|