使用天气预报api接口

使用天气预报api接口

import requests
import json

city = input("城市:")
url = 'http://v.juhe.cn/weather/index?format=2&cityname={}&key=你的key'.format(city)
res = requests.get(url)
json_data = json.loads(res.text)

print("temperature:",json_data['result']['today']['temperature'])
print("weather:",json_data['result']['today']['weather'])
print("wind:",json_data['result']['today']['wind'])
print("week:",json_data['result']['today']['week'])
print("city:",json_data['result']['today']['city'])
print("date_y:",json_data['result']['today']['date_y'])
print("dressing_advice:",json_data['result']['today']['dressing_advice'])

使用天气预报api接口_第1张图片

你可能感兴趣的:(爬虫,python)