1.获取天气
import requests
import math
def get_weather(city):
url = "http://autodev.openspeech.cn/csp/api/v2.1/weather?openId=aiuicus&clientType=android&sign=android&city=" + city
res = requests.get(url).json()
weather = res['data']['list'][0]
return weather['weather'], math.floor(weather['temp']), math.floor(weather['high']), math.floor(weather['low'])
get_weather("深圳")
2.获取沙雕语句
def get_words():
words = requests.get("https://api.shadiao.pro/chp")
if words.status_code != 200:
return get_words()
return words.json()['data']['text']
get_words()
#链接2:https://api.lovelive.tools/api/SweetNothings/1/Serialization/text?genderType=M