基於python3+api獲取金山詞霸每日一句

獲取金山詞霸每日一句,英文和翻譯

from __future__ import unicode_literals
from threading import Timer
import requests

def get_newsDay():
    #獲取金山詞霸每日一句,英文和翻譯
    url = "http://open.iciba.com/dsapi/"
    r = requests.get(url)
    contents = r.json()['content'] #英文部分
    note= r.json()['note'] #中文部分
    print("原文:",contents)
    print("翻譯:",note)

if __name__ == "__main__":
    get_newsDay()

運行結果

在這裏插入圖片描述
附:金山詞霸的json格式字段解析

{
	'sid':'' #每日一句ID
	'tts': '' #音頻地址
	'content':'' #英文內容
	'note': '' #中文內容
	'love': '' #每日一句喜歡個數
	'translation':'' #詞霸小編
	'picture': '' #圖片地址
	'picture2': '' #大圖片地址
	'caption':'' #標題
	'dateline':'' #時間
	's_pv':'' #瀏覽數
	'sp_pv':'' #語音評測瀏覽數
	'tags':'' #相關標籤
	'fenxiang_img':'' #合成圖片,建議分享微博用的
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章