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)