mirror of
https://github.com/HIllya51/LunaTranslator.git
synced 2025-01-01 10:04:12 +08:00
qqimt
This commit is contained in:
parent
c7af6535d0
commit
0bb8abc871
@ -1,41 +1,56 @@
|
|||||||
from translator.basetranslator import basetrans
|
from translator.basetranslator import basetrans
|
||||||
|
import uuid, time
|
||||||
|
|
||||||
|
|
||||||
class TS(basetrans):
|
class TS(basetrans):
|
||||||
|
|
||||||
def translate(self, query):
|
def translate(self, query):
|
||||||
|
|
||||||
headers = {
|
headers = {
|
||||||
"authority": "transmart.qq.com",
|
'accept': 'application/json, text/plain, */*',
|
||||||
"accept": "*/*",
|
'accept-language': 'zh-CN,zh;q=0.9,ar;q=0.8,sq;q=0.7,ru;q=0.6',
|
||||||
"accept-language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
|
'content-type': 'application/json',
|
||||||
"cache-control": "no-cache",
|
'origin': 'https://transmart.qq.com',
|
||||||
#'content-type': 'text/plain;charset=UTF-8',
|
'priority': 'u=1, i',
|
||||||
"origin": "chrome-extension://bcgpmkngbhpgdgbjgbaoddljkbabdkmm",
|
'referer': 'https://transmart.qq.com/zh-CN/index?sourcelang=zh&targetlang=en&source=%E6%B5%8B%E8%AF%951%0A%E6%B5%8B%E8%AF%951%E8%AF%B7%E6%B1%82',
|
||||||
"pragma": "no-cache",
|
'sec-ch-ua': '"Chromium";v="124", "Google Chrome";v="124", "Not-A.Brand";v="99"',
|
||||||
"sec-fetch-dest": "empty",
|
'sec-ch-ua-mobile': '?0',
|
||||||
"sec-fetch-mode": "cors",
|
'sec-ch-ua-platform': '"Windows"',
|
||||||
"sec-fetch-site": "none",
|
'sec-fetch-dest': 'empty',
|
||||||
"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.53",
|
'sec-fetch-mode': 'cors',
|
||||||
|
'sec-fetch-site': 'same-origin',
|
||||||
|
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36',
|
||||||
|
'x-requested-with': 'XMLHttpRequest',
|
||||||
}
|
}
|
||||||
|
|
||||||
data = {
|
json_data = {
|
||||||
"header": {
|
"header": {
|
||||||
"fn": "auto_translation_block",
|
"fn": "auto_translation",
|
||||||
"client_key": "ddsdasdsadasuMzYg",
|
"session": "",
|
||||||
|
"client_key": "browser-chrome-124.0.0-Windows_10-"
|
||||||
|
+ str(uuid.uuid4())
|
||||||
|
+ "-"
|
||||||
|
+ str(int(time.time())),
|
||||||
|
"user": "",
|
||||||
},
|
},
|
||||||
|
"type": "plain",
|
||||||
|
"model_category": "normal",
|
||||||
|
"text_domain": "general",
|
||||||
"source": {
|
"source": {
|
||||||
"lang": self.srclang,
|
"lang": self.srclang,
|
||||||
"text_block": query,
|
"text_list": [
|
||||||
"orig_text_block": "",
|
"",
|
||||||
"orig_url": "https://www.baidu.com/",
|
query,
|
||||||
|
"",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
"target": {
|
||||||
|
"lang": self.tgtlang,
|
||||||
},
|
},
|
||||||
"target": {"lang": self.tgtlang},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
response = self.proxysession.post(
|
response = self.proxysession.post(
|
||||||
"https://transmart.qq.com/api/imt", headers=headers, json=data
|
"https://transmart.qq.com/api/imt", headers=headers, json=json_data
|
||||||
)
|
)
|
||||||
return response.json()["auto_translation"]
|
|
||||||
|
|
||||||
def show(self, res):
|
return "".join(response.json()["auto_translation"])
|
||||||
print("百度", "\033[0;32;47m", res, "\033[0m", flush=True)
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user