wiki:en/ProgrammingRobotsCourse/GettingWwwInfo

Version 2 (modified by xrambous, 4 years ago) (diff)

--

PV277 Programming Applications for Social Robots (autumn 2019)

How to get info from web?

Use API

If API exists, you can usually use JSON data after send the right parameters. Example to get weather data.

import requests
url = "http://api.openweathermap.org/data/2.5/weather"

params = {'q': 'Brno',
          'units': 'metric',
          'lang': 'cz'}

r = requests.get(url=url, params=params)
data = r.json()

print(data['main']['temp'])

Attachments (7)

Download all attachments as: .zip