# -*- ecoding: utf-8 -*-
# @ModuleName: test004
# @Function:
# @Author: darling
# @Time: 2022-04-15 17:46
import requests
# linux执行登陆请调用下面的这句
def get_news():
"""获取金山词霸每日一句,英文和翻译"""
url = "http://open.iciba.com/dsapi/"
r = requests.get(url)
content = r.json()['content']
note = r.json()['note']
return content, note
if __name__ == "__main__":
res = get_news()
print(res)
直接访问 接口地址,得到的是json 字符串,这里将字符串进行转json并取到其中的元素
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)