有道翻译网址
【例1-1】利用request模块
import requests
import json
def fanyi(word="你没有输入要翻译的内容"):
url ="http://fanyi.youdao.com/translate?smartresult=dict&smartresult=rule&smartresult=ugc&sessionFrom=null"
data={
'type':"AUTO",
'i':word,
"doctype":"json",
"keyfrom":"fanyi.web",
"ue":"UTF-8",
"action":"FY_BY_CLICKBUTTON",
"typoResult":"true"
}
response = requests.post(url,data=data)
print(json.loads(response.text)["translateResult"][0][0]["src"],":",
json.loads(response.text)["translateResult"][0][0]["tgt"])
fanyi("词语")