/
Horys
/
Python
Обзор
Документация
Войти
/
Horys
/
Python
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
weather_parser.py
21 строка
808 B
Виктор
Create: weather_parser.py
14 июл 2026, 13:05
Верифицирован
14 июл 2026, 13:05
8aca498
Код
Авторство
О чём код?
import requests city = (input('Введите город: \n')) headers = {"User-Agent": "WatherParser"} url = f"https://nominatim.openstreetmap.org/search?q={city}&format=json" response = requests.get(url, headers=headers) data = response.json() if not data: print("Город не найден") exit() width = data[0]['lat'] height = data[0]['lon'] weather_url = f'https://api.open-meteo.com/v1/forecast?latitude={width}&longitude={height}¤t_weather=true' weather_response = requests.get(weather_url) weather_data = weather_response.json() temp = weather_data['current_weather']['temperature'] wind = weather_data['current_weather']['windspeed'] print(f"Сейчас температура в городе: {city} \nТемпература {temp}, \nСкорость ветра {wind}")