This commit is contained in:
恍兮惚兮 2024-07-17 01:01:50 +08:00
parent e33c0df92e
commit 70942a831e

View File

@ -10,30 +10,29 @@ class TS(basetrans):
def translate(self, content): def translate(self, content):
headers = { headers = {
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9", "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
"Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6", "Accept-Language": "zh-CN,zh;q=0.9",
"Cache-Control": "no-cache",
"Connection": "keep-alive", "Connection": "keep-alive",
"Pragma": "no-cache",
"Sec-Fetch-Dest": "document", "Sec-Fetch-Dest": "document",
"Sec-Fetch-Mode": "navigate", "Sec-Fetch-Mode": "navigate",
"Sec-Fetch-Site": "none", "Sec-Fetch-Site": "none",
"Sec-Fetch-User": "?1", "Sec-Fetch-User": "?1",
"Upgrade-Insecure-Requests": "1", "Upgrade-Insecure-Requests": "1",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36 Edg/105.0.1343.50", "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36",
"sec-ch-ua": '"Microsoft Edge";v="105", " Not;A Brand";v="99", "Chromium";v="105"', "sec-ch-ua": '"Not/A)Brand";v="8", "Chromium";v="126", "Google Chrome";v="126"',
"sec-ch-ua-mobile": "?0", "sec-ch-ua-mobile": "?0",
"sec-ch-ua-platform": '"Windows"', "sec-ch-ua-platform": '"Windows"',
} }
params = {
"keyword": content,
"transfrom": self.srclang,
"transto": self.tgtlang,
"model": "general",
}
res = self.proxysession.get( res = self.proxysession.get(
"https://fanyi.sogou.com/text?keyword=" "https://fanyi.sogou.com/text", params=params, headers=headers
+ quote(content)
+ "&transfrom="
+ self.srclang
+ "&transto"
+ self.tgtlang
+ "&model=general",
headers=headers,
) )
res = re.search( res = re.search(
'<p id="trans-result" class="output-val" style="white-space: pre-line">([\\s\\S]*?)</p>', '<p id="trans-result" class="output-val" style="white-space: pre-line">([\\s\\S]*?)</p>',