# coding=utf-8
# au: LuoWeiMing
# data:2018.08.30
import requests
import json
def get_translate_date(word = None):
while True:
word = input("请输入你需要翻译的语句:(Q退出)")
if word == 'Q':
print('欢迎下次使用^_^')
break
else:
url = "http://fanyi.youdao.com/translate?smartresult=dict&smartresult=rule"
payload = {
'i': word,
'from': 'AUTO',
'to': 'AUTO',
'smartresult': 'dict',
'client': 'fanyideskweb',
'salt': '1535610325271',
'sign': '7ec6f0db4822104f5fa0b8d8dd28cee7',
'doctype': 'json',
'version': '2.1',
'keyfrom': 'fanyi.web',
'action': 'FY_BY_REALTIME',
'typoResult': 'false'
}
response = requests.post(url, data=payload)
content = json.loads(response.text)
print(content['translateResult'][0][0]['tgt'])
if __name__ == '__main__':
get_translate_date()
爬虫小日记---跟有道词典互动
最新推荐文章于 2023-07-04 16:26:37 发布