import urllib.requestimport urllib.parseimport jsoncontent=input(‘请输入你要翻译文本\n‘)data={}data[‘i‘] = contentdata[‘from‘] = ‘AUTO‘data[‘to‘] = ‘AUTO‘data[‘smartresult‘] = ‘dict‘data[‘client‘] = ‘fanyideskweb‘data[‘salt‘] = ‘f‘data[‘sign‘] = ‘sign‘data[‘doctype‘] = ‘json‘data[‘version‘] = ‘2.1‘data[‘keyfrom‘] = ‘fanyi.web‘data[‘action‘] = ‘FY_BY_CL1CKBUTTON‘data[‘typoResult‘] = ‘true‘url=‘http://fanyi.youdao.com/translate‘data=urllib.parse.urlencode(data).encode(‘utf-8‘)request=urllib.request.Request(url=url,data=data)response=urllib.request.urlopen(request)html=response.read().decode(‘utf-8‘)html=json.loads(html)print(html[‘translateResult‘][0][0][‘tgt‘])
原文地址:https://www.cnblogs.com/wantao/p/8169353.html
时间: 2024-11-09 02:20:40