mirror of
https://github.com/HIllya51/LunaTranslator.git
synced 2024-12-29 16:44:13 +08:00
fix
This commit is contained in:
parent
099fb4764d
commit
5b91087128
@ -346,13 +346,13 @@ class Session:
|
|||||||
verify=False,
|
verify=False,
|
||||||
cert=None,
|
cert=None,
|
||||||
):
|
):
|
||||||
|
requester = self.requester
|
||||||
if cookies:
|
if cookies:
|
||||||
self.cookies.update(cookies)
|
self.cookies.update(cookies)
|
||||||
_h = self.headers.copy()
|
_h = self.headers.copy()
|
||||||
if headers:
|
if headers:
|
||||||
_h.update(headers)
|
_h.update(headers)
|
||||||
response = self.requester.request(
|
response = requester.request(
|
||||||
method.upper(),
|
method.upper(),
|
||||||
url,
|
url,
|
||||||
params,
|
params,
|
||||||
|
@ -4,7 +4,6 @@ from translator.basetranslator import basetrans
|
|||||||
import random
|
import random
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class TS(basetrans):
|
class TS(basetrans):
|
||||||
def langmap(self):
|
def langmap(self):
|
||||||
return {"zh": "zh-CHS"}
|
return {"zh": "zh-CHS"}
|
||||||
@ -27,7 +26,7 @@ class TS(basetrans):
|
|||||||
}
|
}
|
||||||
|
|
||||||
def inittranslator(self):
|
def inittranslator(self):
|
||||||
self.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/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",
|
"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",
|
"Cache-Control": "no-cache",
|
||||||
@ -45,9 +44,7 @@ class TS(basetrans):
|
|||||||
}
|
}
|
||||||
# proxies = { "http": None, "https": None}
|
# proxies = { "http": None, "https": None}
|
||||||
|
|
||||||
self.proxysession.trust_env = False
|
self.proxysession.get("https://fanyi.youdao.com", headers=headers)
|
||||||
self.proxysession.headers.update(self.headers)
|
|
||||||
self.proxysession.get("https://fanyi.youdao.com")
|
|
||||||
|
|
||||||
def translate(self, content):
|
def translate(self, content):
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ class TS(basetrans):
|
|||||||
return {"zh": "zh-CHS"}
|
return {"zh": "zh-CHS"}
|
||||||
|
|
||||||
def inittranslator(self):
|
def inittranslator(self):
|
||||||
self.headers = {
|
headers = {
|
||||||
"authority": "ai.youdao.com",
|
"authority": "ai.youdao.com",
|
||||||
"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.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.9",
|
||||||
"accept-language": "zh-CN,zh;q=0.9",
|
"accept-language": "zh-CN,zh;q=0.9",
|
||||||
@ -22,9 +22,9 @@ class TS(basetrans):
|
|||||||
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36",
|
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36",
|
||||||
}
|
}
|
||||||
|
|
||||||
self.proxysession.trust_env = False
|
self.proxysession.get(
|
||||||
self.proxysession.headers.update(self.headers)
|
"https://ai.youdao.com/product-fanyi-text.s", headers=headers
|
||||||
self.proxysession.get("https://ai.youdao.com/product-fanyi-text.s")
|
)
|
||||||
|
|
||||||
def translate(self, content):
|
def translate(self, content):
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user