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)
python利用爬虫实现有道翻译
猜你喜欢
转载自blog.csdn.net/qq_38900441/article/details/86707354
今日推荐
周排行