sign.js
var cry = require("crypto")
d = "fanyideskweb"
u = "webfanyi"
var e = (new Date).getTime()
// var e = 1695965834800
function A(e) {
// return r.a.createHash("md5").update(e.toString()).digest("hex")
return cry.MD5(e).toString()
}
function w(e, t) {
console.log(`client=${d}&mysticTime=${e}&product=${u}&key=${t}`)
return A(`client=${d}&mysticTime=${e}&product=${u}&key=${t}`)
}
function sign(){
var t = "fsdsogkndfokasodnaso"
return [w(e,t),e]
}
console.log(sign())
main.py
import requests
import execjs
# 执行js函数
with open("sign.js", "r") as f:
JSCode = f.read()
docjs = execjs.compile(JSCode)
sign,time = docjs.call('sign')
text = input("请输入要翻译的内容: ")
url = "https://dict.youdao.com/webtranslate"
myData = {
"i":text,
"from":"auto",
"to":"",
"dictResult":"true",
"keyid":"webfanyi",
"sign": sign,
"client":"fanyideskweb",
"product":"webfanyi",
"appVersion":"1.0.0",
"vendor":"web",
"pointParam":"client,mysticTime,product",
"mysticTime":time,
"keyfrom":"fanyi.web",
"mid":"1",
"screen":"1",
"model":"1",
"network":"wifi",
"abtest":"0",
"yduuid":"abcdefg"
}
myHeaders = {
"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36"
}
res = requests.post(url,headers = myHeaders,data = myData)
print(res.text)
1 条评论
研表究明,汉字的序顺并不定一能影阅响读,比如当你看完这句话后,才发这现里的字全是都乱的。 http://appdownload.cc