有道翻译

import time
import requests
import execjs
d = execjs.get().compile(open('decrypt.js','r',encoding='utf-8').read())
headers = {
    'Accept': 'application/json, text/plain, */*',
    'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6',
    'Connection': 'keep-alive',
    'Content-Type': 'application/x-www-form-urlencoded',
    'Origin': 'https://fanyi.youdao.com',
    'Referer': 'https://fanyi.youdao.com/',
    'Sec-Fetch-Dest': 'empty',
    'Sec-Fetch-Mode': 'cors',
    'Sec-Fetch-Site': 'same-site',
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36 Edg/113.0.1774.35',
    'sec-ch-ua': '"Microsoft Edge";v="113", "Chromium";v="113", "Not-A.Brand";v="24"',
    'sec-ch-ua-mobile': '?0',
    'sec-ch-ua-platform': '"Windows"',
}
cook = requests.get(f'https://rlogs.youdao.com/rlog.php?_npid=fanyiweb&_ncat=event&_nssn=NULL&_nver=1.2.0&_ntms={time.time()}&show=pop-up_windows&/=NULL&screen=1707*1067',headers=headers)
data = d.call('getMessage','hehe')
response = requests.post('https://dict.youdao.com/webtranslate', cookies=cook.cookies, headers=headers, data=data)
print(d.call('Youdao',response.text))
代码

js:

链接:https://pan.baidu.com/s/1R4Upmh5iAD7qJawOyB5bjg
提取码:6666

js复制下来的 要是有去除没用的js 方法就好了

posted @ 2023-05-14 10:11  inks  阅读(22)  评论(0)    收藏  举报