网址
接口
Python代码
# -*- coding: utf-8 -*-
# @Author: Null119 微信公众号/网站:治廷君
# @Desc: { 有道翻译 }
# @Date: { 2022-12-16 }
import requests
import time
import hashlib
import json,jsonpath
import execjs
ctx = execjs.compile(open('./youdao.js',encoding='utf-8').read())
def getdata(words):
s = requests.session()
s.get('http://fanyi.youdao.com/')
headers={
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36',
'Referer': 'http://fanyi.youdao.com/'
}
api = 'http://dict.youdao.com/webtranslate?smartresult=dict&smartresult=rule'
ts = str(int(time.time()*1000))
enstr=f'client=fanyideskweb&mysticTime={ts}&product=webfanyi&key=fsdsogkndfokasodnaso'
sign = hashlib.md5(enstr.encode(encoding='utf-8')).hexdigest()
print('sign:',sign)
postdata = {
'i': words,
'from': 'AUTO',
'to': 'AUTO',
'dictResult':'true',
'keyid':'webfanyi',
'sign': sign,
'client': 'fanyideskweb',
'product':'webfanyi',
'appVersion':'1.0.0',
'vendor':'web',
'pointParam':'client,mysticTime,product',
'mysticTime': ts,
'keyfrom': 'fanyi.web',
}
html =s.post(url=api,data=postdata,headers=headers)
enhtml=html.text
print('Response:',enhtml)
endata = str(ctx.eval('decrypt("' + enhtml + '")'))
print('Decrypt:',endata)
tgt = jsonpath.jsonpath(json.loads(endata),'$..tgt')
result=''
for i in tgt:
result = result + i + ' , '
return '%s : %s' % (words , result[0:-3])
if __name__ == '__main__':
print(getdata('happy'))
JS代码
const crypto = require('crypto');
const m1 = crypto.createHash('md5');
const m2 = crypto.createHash('md5');
function decrypt(endata) {
var keystr='ydsecret://query/key/B*RGygVywfNBwpmBaZg*WT7SIOUP2T0C9WHMZN39j^DAdaZhAnxvGcCY6VYFwnHl'
var ivstr='ydsecret://query/iv/C@lZe2YzHtZ2CYgaXKSVfsb7Y4QWHjITPPZ0nQp87fBeJ!Iv6v^6fvi2WN@bYpJ4'
var a = Buffer.alloc(16, m1.update(keystr).digest())
, r = Buffer.alloc(16, m2.update(ivstr).digest())
, i = crypto.createDecipheriv("aes-128-cbc", a, r);
let s = i.update(endata, "base64", "utf-8");
return s += i.final("utf-8"),
s
}
// var endata='Z21kD9ZK1ke6ugku2ccWu4n6eLnvoDT0YgGi0y3g-v0B9sYqg8L9D6UERNozYOHqObgLiV_67fNVIRkhTDVUD_vf5S50MCebp-dLm-ZZAJ_3xBSUsFRvsVPGoG0Zoy1uZNfGf_YW31q4FFvkLy5WD34LrIQuzTEIT5A4aCT049DbOEwt6_ZFYVwmQodRBr1uMC1Wm1ix5aekg0LMMUZXebdkhCh8bJnZ20cN5zUAxiJOcZHF-OM5m_eCBeHw7rq2zyPFD4EkcoEfjh4NKEe8i4g9nsxD_kfkVWy80wHaVez3Qn75M2RGIlPWBi9mlWK_-5hG0cteTNpKxFm0ktyu5b72nSf7cXUBLhIMHnm7Nw1YBEmhycy9uunb7VnVi-8JOn5sBBYCq1i7NpPJDZ1JMRTv1GbY-Nyi3gBkaTrEnnzoJTl6H8RqO41sNVFcbiv8viDkhrApJ5zrSWlSXNjLe9USd_HWlxGqrN2DhuTrHsA='
// console.log(decrypt((endata)))
本站所有资源版权均属于原作者所有,这里所提供资源均只能用于参考学习使用,请在下载后24小时内删除,严禁商用。若由于商用引起版权纠纷,一切责任均由使用者承担。
【注意:本站发布资源来源于网络搜集,均有较强时效性,请在下载前注意查看文章资源发布或更新时间,距离当前时间太久的资源不建议下载,特别是安卓专区相关资源,会有大概率失效无法使用】
评论(0)