Changes between Version 1 and Version 2 of en/ProgrammingRobotsCourse/GettingWwwInfo


Ignore:
Timestamp:
Oct 28, 2019, 4:13:53 PM (13 months ago)
Author:
xrambous
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • en/ProgrammingRobotsCourse/GettingWwwInfo

    v1 v2  
    33== How to get info from web?
    44
     5=== Use API
     6If API exists, you can usually use JSON data after send the right parameters. Example to get weather data.
    57
    6 *
     8{{{#!python
     9import requests
     10url = "http://api.openweathermap.org/data/2.5/weather"
     11
     12params = {'q': 'Brno',
     13          'units': 'metric',
     14          'lang': 'cz'}
     15
     16r = requests.get(url=url, params=params)
     17data = r.json()
     18
     19print(data['main']['temp'])
     20}}}