mirror of
https://github.com/HIllya51/LunaTranslator.git
synced 2024-12-28 08:04:13 +08:00
fix
This commit is contained in:
parent
099fb4764d
commit
5b91087128
@ -322,7 +322,7 @@ class Session:
|
||||
from network.winhttp.requester import Requester
|
||||
self._requester = Requester()
|
||||
self._libidx = globalconfig["network"]
|
||||
|
||||
|
||||
self.headers.update({"Accept-Encoding": self.requester.Accept_Encoding})
|
||||
self.headers.update({"User-Agent": self.requester.default_UA})
|
||||
return self._requester
|
||||
@ -346,13 +346,13 @@ class Session:
|
||||
verify=False,
|
||||
cert=None,
|
||||
):
|
||||
|
||||
requester = self.requester
|
||||
if cookies:
|
||||
self.cookies.update(cookies)
|
||||
_h = self.headers.copy()
|
||||
if headers:
|
||||
_h.update(headers)
|
||||
response = self.requester.request(
|
||||
response = requester.request(
|
||||
method.upper(),
|
||||
url,
|
||||
params,
|
||||
|
@ -4,7 +4,6 @@ from translator.basetranslator import basetrans
|
||||
import random
|
||||
|
||||
|
||||
|
||||
class TS(basetrans):
|
||||
def langmap(self):
|
||||
return {"zh": "zh-CHS"}
|
||||
@ -27,7 +26,7 @@ class TS(basetrans):
|
||||
}
|
||||
|
||||
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-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",
|
||||
@ -45,9 +44,7 @@ class TS(basetrans):
|
||||
}
|
||||
# proxies = { "http": None, "https": None}
|
||||
|
||||
self.proxysession.trust_env = False
|
||||
self.proxysession.headers.update(self.headers)
|
||||
self.proxysession.get("https://fanyi.youdao.com")
|
||||
self.proxysession.get("https://fanyi.youdao.com", headers=headers)
|
||||
|
||||
def translate(self, content):
|
||||
|
||||
|
@ -6,7 +6,7 @@ class TS(basetrans):
|
||||
return {"zh": "zh-CHS"}
|
||||
|
||||
def inittranslator(self):
|
||||
self.headers = {
|
||||
headers = {
|
||||
"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-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",
|
||||
}
|
||||
|
||||
self.proxysession.trust_env = False
|
||||
self.proxysession.headers.update(self.headers)
|
||||
self.proxysession.get("https://ai.youdao.com/product-fanyi-text.s")
|
||||
self.proxysession.get(
|
||||
"https://ai.youdao.com/product-fanyi-text.s", headers=headers
|
||||
)
|
||||
|
||||
def translate(self, content):
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user