有道翻译、百度翻译

news/2024/11/29 1:43:09/

有道

import requests
import time
import hashliburl = "http://fanyi.youdao.com/translate_o?smartresult=dict^&smartresult=rule"'''
JS加密算法
bv = n.md5(navigator.appVersion);
ts = "" + (new Date).getTime();
salt = ts + parseInt(10 * Math.random(), 10);
sign: n.md5("fanyideskweb" + "猫" + salt + "n%A-rKaT5fb[Gy?;N5@Tj")
'''# 将参数用python重写
key_word = 'I love you!'
t = time.time()
ts = str(int((round(t * 1000))))
salt = ts + "7"
str1 = "fanyideskweb" + key_word + salt + "n%A-rKaT5fb[Gy?;N5@Tj"
sign = hashlib.md5(str1.encode(encoding="UTF-8")).hexdigest()payload = {'i': key_word,'from': 'AUTO','to': 'AUTO','smartresult': 'dict','client': 'fanyideskweb','salt': salt,'sign': sign,'ts': ts,'bv': '710f3e24cb0088b9d9ea448919deb3bb','doctype': 'json','version': '2.1','keyfrom': 'fanyi.web','action': 'FY_BY_CLICKBUTTION'
}headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36','Referer': 'http://fanyi.youdao.com/','Cookie': 'OUTFOX_SEARCH_USER_ID=1604595327@10.108.160.17; JSESSIONID=aaa9yHIwIeEoE9CHIy4ax; OUTFOX_SEARCH_USER_ID_NCOO=2126689204.9151545; ___rl__test__cookies=1581494179267'
}response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
result = response.json()["translateResult"][0][0]["tgt"]
print(result)

百度

import requests
import execjsurl = "https://fanyi.baidu.com/v2transapi?from=zh^&to=en"
key_word = '我爱你'with open('hello_1.js', 'r', encoding='utf-8') as f:ctx = execjs.compile(f.read())
sign = ctx.call('e', key_word)payload = {'from': 'zh','to': 'en','query': key_word,'transtype': 'translang','simple_means_flag': '3','sign': sign,'token': '1562ecf4330b37f46bfd5185d9c9cbff'
}
headers = {'authority': 'fanyi.baidu.com','pragma': 'no-cache','cache-control': 'no-cache','accept': '*/*','origin': 'https://fanyi.baidu.com','x-requested-with': 'XMLHttpRequest','user-agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36','content-type': 'application/x-www-form-urlencoded; charset=UTF-8','sec-fetch-site': 'same-origin','sec-fetch-mode': 'cors','referer': 'https://fanyi.baidu.com/?aldtype=16047','accept-encoding': 'gzip, deflate, br','accept-language': 'zh-CN,zh;q=0.9','cookie': 'FANYI_WORD_SWITCH=1; REALTIME_TRANS_SWITCH=1; HISTORY_SWITCH=1; SOUND_SPD_SWITCH=1; SOUND_PREFER_SWITCH=1; APPGUIDE_8_2_2=1; PSTM=1581416231; BAIDUID=E1445DA3B2549E17ADE9E92FCEEB41D3:FG=1; BIDUPSID=8EB281752879A595CABE058E3B37FC0A; BDORZ=B490B5EBF6F3CD402E515D22BCDA1598; delPer=0; H_PS_PSSID=30748_1450_21082_26350_22157; PSINO=7; ZD_ENTRY=baidu; Hm_lvt_64ecd82404c51e03dc91cb9e8c025574=1580872897,1581497347; Hm_lpvt_64ecd82404c51e03dc91cb9e8c025574=1581497700; __yjsv5_shitong=1.0_7_8d4ad120b780566835e6224589774f417a25_300_1581497703466_36.148.50.78_e932b806; yjs_js_security_passport=117123db23780d3f02adb2a169dba21984444955_1581497704_js; from_lang_often=^%^5B^%^7B^%^22value^%^22^%^3A^%^22en^%^22^%^2C^%^22text^%^22^%^3A^%^22^%^u82F1^%^u8BED^%^22^%^7D^%^2C^%^7B^%^22value^%^22^%^3A^%^22zh^%^22^%^2C^%^22text^%^22^%^3A^%^22^%^u4E2D^%^u6587^%^22^%^7D^%^5D; to_lang_often=^%^5B^%^7B^%^22value^%^22^%^3A^%^22zh^%^22^%^2C^%^22text^%^22^%^3A^%^22^%^u4E2D^%^u6587^%^22^%^7D^%^2C^%^7B^%^22value^%^22^%^3A^%^22en^%^22^%^2C^%^22text^%^22^%^3A^%^22^%^u82F1^%^u8BED^%^22^%^7D^%^5D'
}response = requests.request("POST", url, headers=headers, data=payload)
print(response.json())
result = response.json()['trans_result']['data'][0]['dst']
print(result)

JS

function e(r) {var o = r.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g);if (null === o) {var t = r.length;t > 30 && (r = "" + r.substr(0, 10) + r.substr(Math.floor(t / 2) - 5, 10) + r.substr(-10, 10))} else {for (var e = r.split(/[\uD800-\uDBFF][\uDC00-\uDFFF]/), C = 0, h = e.length, f = []; h > C; C++)"" !== e[C] && f.push.apply(f, a(e[C].split(""))),C !== h - 1 && f.push(o[C]);var g = f.length;g > 30 && (r = f.slice(0, 10).join("") + f.slice(Math.floor(g / 2) - 5, Math.floor(g / 2) + 5).join("") + f.slice(-10).join(""))}var u = void 0, l = "" + String.fromCharCode(103) + String.fromCharCode(116) + String.fromCharCode(107);u = null !== i ? i : (i = window[l] || "") || "";for (var d = u.split("."), m = Number(d[0]) || 0, s = Number(d[1]) || 0, S = [], c = 0, v = 0; v < r.length; v++) {var A = r.charCodeAt(v);128 > A ? S[c++] = A : (2048 > A ? S[c++] = A >> 6 | 192 : (55296 === (64512 & A) && v + 1 < r.length && 56320 === (64512 & r.charCodeAt(v + 1)) ? (A = 65536 + ((1023 & A) << 10) + (1023 & r.charCodeAt(++v)),S[c++] = A >> 18 | 240,S[c++] = A >> 12 & 63 | 128) : S[c++] = A >> 12 | 224,S[c++] = A >> 6 & 63 | 128),S[c++] = 63 & A | 128)}for (var p = m, F = "" + String.fromCharCode(43) + String.fromCharCode(45) + String.fromCharCode(97) + ("" + String.fromCharCode(94) + String.fromCharCode(43) + String.fromCharCode(54)), D = "" + String.fromCharCode(43) + String.fromCharCode(45) + String.fromCharCode(51) + ("" + String.fromCharCode(94) + String.fromCharCode(43) + String.fromCharCode(98)) + ("" + String.fromCharCode(43) + String.fromCharCode(45) + String.fromCharCode(102)), b = 0; b < S.length; b++)p += S[b],p = n(p, F);return p = n(p, D),p ^= s,0 > p && (p = (2147483647 & p) + 2147483648),p %= 1e6,p.toString() + "." + (p ^ m)}function n(r, o) {for (var t = 0; t < o.length - 2; t += 3) {var a = o.charAt(t + 2);a = a >= "a" ? a.charCodeAt(0) - 87 : Number(a),a = "+" === o.charAt(t + 1) ? r >>> a : r << a,r = "+" === o.charAt(t) ? r + a & 4294967295 : r ^ a}return r}//var i = null; 此为源代码
//u = null !== i ? i : (i = window[l] || "") || "";  在浏览器中执行window对象,赋值给i
var i = "320305.131321201"

http://www.ppmy.cn/news/869231.html

相关文章

Ubuntu下安装网易有道词典

1、下载安装包 进入网易有道词典多平台下载&#xff0c;网址&#xff1a;多平台下载 - 有道词典。 选择并下载LInux版本下的Ubuntu&#xff08;amd64&#xff09;版。 2、命令行安装 Ubuntu高版本的图形化安装界面就不说了&#xff0c;大致长这样&#xff1a; 说些低版本安装时…

有道词典官方下载【词典相关的服务与软件】

有道词典官方下载 有道词典免费下载 软件大小&#xff1a; MB 软件语言&#xff1a;简体中文 软件性质&#xff1a;应用软件 软件授权&#xff1a;免费共享软件 软件等级&#xff1a;2 更新时间&#xff1a;2013-03-08 11:45:53 应用平台&#xff1a;windows XP/Vista/window…

ubuntu20.04下载安装有道词典

进入官网下载.deb压缩包 http://cidian.youdao.com/multi.html 打开终端&#xff0c;输入&#xff1a;sudo dpkg -i youdao-dict_6.0.0-ubuntu-amd64.deb 若出现错误&#xff1a;youdao-dict 输入&#xff1a;sudo apt-get -f install 再次输入sudo dpkg -i youdao-dict_6.0…

Translate插件的有道翻译

在plugins下载Translate插件 setting-> Tools->Translation 没有id和密钥就申请注册 登录后 创建应用 创建成功后输入id和密钥 点击鼠标右键即可使用 翻译效果 over

有道翻译词典

以前一直在使用金山&#xff0c;发现金山在某些方便不尽如人意&#xff0c;比如在做翻译时&#xff0c;相信有不少朋友遇到和我相同的问题: 抱歉系统繁忙~~~~ 因此在繁忙的工作下&#xff0c;也就开始选用有道了 下载个桌面版给自己提供翻译: http://cidian.youdao.com/ 有需…

离线翻译android开发,有道翻译官推出Android版 可离线翻译多国语言

日前&#xff0c;有道翻译官正式推出安卓版&#xff0c;凭借多国语言离线翻译和国内首创的多语种摄像头翻译等功能&#xff0c;为广大用户提供最便捷实用的翻译体验。 有道翻译官曾在iOS平台上大放异彩&#xff0c;上线当日&#xff0c;即取得了App Store 总榜第二、效率类排行…

有道翻译软件下载地址

http://cidian.youdao.com/ 来自 “ ITPUB博客 ” &#xff0c;链接&#xff1a;http://blog.itpub.net/9240380/viewspace-711490/&#xff0c;如需转载&#xff0c;请注明出处&#xff0c;否则将追究法律责任。 转载于:http://blog.itpub.net/9240380/viewspace-711490/

C# 调用C++动态库注意事项

最近项目上需要在C#中调用C&#xff0c;期间遇到不少坑&#xff0c;总结如下&#xff1a; 入参 c > c# long > int LPSTR > string 出参 c > c# __int64 * > ref Int64 long * >ref int char* >StringBuilder 1.in const char* 对应C…