加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
getApi.py 3.80 KB
一键复制 编辑 原始数据 按行查看 历史
GuLu 提交于 2022-09-19 11:26 . python实现
import http.client
import urllib
import json
# 云音乐热评
def getReP():
conn = http.client.HTTPSConnection('api.tianapi.com') # 接口域名
params = urllib.parse.urlencode({'key': ''})
headers = {'Content-type': 'application/x-www-form-urlencoded'}
conn.request('POST', '/hotreview/index', params, headers)
res = conn.getresponse()
data = res.read()
# 获得json数据
data_json = data.decode('utf-8')
# json数据>>>python dict 数据
data_python = json.loads(data_json)
# print(data_python)
# python dict数据>>>需要的list数据
newList = data_python.get('newslist')
# list数据>>>dict数据
newList_dict = newList[0]
# 云音乐热评
content = newList_dict.get('content')
# 热评来源音乐
source = newList_dict.get('source')
return content, source
# 舔狗日记
def getTianGRJ():
conn = http.client.HTTPSConnection('api.tianapi.com') # 接口域名
params = urllib.parse.urlencode({'key': ''})
headers = {'Content-type': 'application/x-www-form-urlencoded'}
conn.request('POST', '/tiangou/index', params, headers)
res = conn.getresponse()
data = res.read()
# 获得json数据
data_json = data.decode('utf-8')
# json数据>>>python dict 数据
data_python = json.loads(data_json)
# print(data_python)
# python dict数据>>>需要的list数据
newList = data_python.get('newslist')
# list数据>>>dict数据
newList_dict = newList[0]
# 云音乐热评
content = newList_dict.get('content')
return content
# print(content)
# 英语一句话
def getEngEvDay():
conn = http.client.HTTPSConnection('api.tianapi.com') # 接口域名
params = urllib.parse.urlencode({'key': ''})
headers = {'Content-type': 'application/x-www-form-urlencoded'}
conn.request('POST', '/ensentence/index', params, headers)
res = conn.getresponse()
data = res.read()
# 获得json数据
data_json = data.decode('utf-8')
# json数据>>>python dict 数据
data_python = json.loads(data_json)
# print(data_python)
# python dict数据>>>需要的list数据
newList = data_python.get('newslist')
# list数据>>>dict数据
newList_dict = newList[0]
# 英语一句话
en = newList_dict.get('en')
zh = newList_dict.get('zh')
content = en + "\n" + zh
return content
# 每日晚安
def getEvDayWanAn():
conn = http.client.HTTPSConnection('api.tianapi.com') # 接口域名
params = urllib.parse.urlencode({'key': ''})
headers = {'Content-type': 'application/x-www-form-urlencoded'}
conn.request('POST', '/wanan/index', params, headers)
res = conn.getresponse()
data = res.read()
# 获得json数据
data_json = data.decode('utf-8')
# json数据>>>python dict 数据
data_python = json.loads(data_json)
# print(data_python)
# python dict数据>>>需要的list数据
newList = data_python.get('newslist')
# list数据>>>dict数据
newList_dict = newList[0]
# 每日晚安
content = newList_dict.get('content')
return content
# print(content)
# 每日早安
def getEvDayZaoAn():
conn = http.client.HTTPSConnection('api.tianapi.com') # 接口域名
params = urllib.parse.urlencode({'key': ''})
headers = {'Content-type': 'application/x-www-form-urlencoded'}
conn.request('POST', '/wanan/index', params, headers)
res = conn.getresponse()
data = res.read()
# 获得json数据
data_json = data.decode('utf-8')
# json数据>>>python dict 数据
data_python = json.loads(data_json)
# print(data_python)
# python dict数据>>>需要的list数据
newList = data_python.get('newslist')
# list数据>>>dict数据
newList_dict = newList[0]
# 每日早安
content = newList_dict.get('content')
return content
# print(content)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化