From 70942a831e34e2bbeb1f12ff0c9609d67bb32e40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=81=8D=E5=85=AE=E6=83=9A=E5=85=AE?= <101191390+HIllya51@users.noreply.github.com> Date: Wed, 17 Jul 2024 01:01:50 +0800 Subject: [PATCH] fix --- .../LunaTranslator/translator/sougou2.py | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/LunaTranslator/LunaTranslator/translator/sougou2.py b/LunaTranslator/LunaTranslator/translator/sougou2.py index a1bfdf83..4f046644 100644 --- a/LunaTranslator/LunaTranslator/translator/sougou2.py +++ b/LunaTranslator/LunaTranslator/translator/sougou2.py @@ -10,30 +10,29 @@ class TS(basetrans): def translate(self, content): 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-Language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6", - "Cache-Control": "no-cache", + "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", "Connection": "keep-alive", - "Pragma": "no-cache", "Sec-Fetch-Dest": "document", "Sec-Fetch-Mode": "navigate", "Sec-Fetch-Site": "none", "Sec-Fetch-User": "?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", - "sec-ch-ua": '"Microsoft Edge";v="105", " Not;A Brand";v="99", "Chromium";v="105"', + "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": '"Not/A)Brand";v="8", "Chromium";v="126", "Google Chrome";v="126"', "sec-ch-ua-mobile": "?0", "sec-ch-ua-platform": '"Windows"', } + + params = { + "keyword": content, + "transfrom": self.srclang, + "transto": self.tgtlang, + "model": "general", + } + res = self.proxysession.get( - "https://fanyi.sogou.com/text?keyword=" - + quote(content) - + "&transfrom=" - + self.srclang - + "&transto" - + self.tgtlang - + "&model=general", - headers=headers, + "https://fanyi.sogou.com/text", params=params, headers=headers ) res = re.search( '

([\\s\\S]*?)

',