自制小型翻譯器 有道

import requests
from bs4 import BeautifulSoup

word=input("請輸入你所要翻譯語句")
url="http://fanyi.youdao.com/translate?smartresult=dict&smartresult=rule"

key={
    "i": word,
    "from": "AUTO",
    "to": "AUTO",
    "smartresult": "dict",
    "client": "fanyideskweb",
    "doctype": "json",
    "version": "2.1",
    "keyfrom": "fanyi.web",
    "action": "FY_BY_REALTIME",
    "typoResult": "true"


 }
html=requests.post(url,data=key)
js=html.json()
print("翻譯結果:" + js['translateResult'][0][0]['tgt'] + '\n')

# soup=BeautifulSoup(html.content,"html.parser")
# print(soup)

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章