From ede02ae43e0553e6c186d95a659a99dc852f84ff Mon Sep 17 00:00:00 2001 From: ygsk10 <78141660+ygsk10@users.noreply.github.com> Date: Sun, 31 Jan 2021 13:30:13 +0800 Subject: [PATCH] Update qqApi.js https://github.com/project-yuki/YUKI/issues/152#issuecomment-744291613 --- config/qqApi.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/config/qqApi.js b/config/qqApi.js index 89f3ee0..3a525dd 100644 --- a/config/qqApi.js +++ b/config/qqApi.js @@ -1,4 +1,5 @@ SESSION_URL = "https://fanyi.qq.com/" +AUTH_URL = "https://fanyi.qq.com/api/aaa123" TRANSLATE_URL = "https://fanyi.qq.com/api/translate" USER_AGENT = @@ -48,17 +49,17 @@ if (!session) { }; initSession = () => { - return Request.get(SESSION_URL, { - jar: session, - gzip: true, + return Request.post(AUTH_URL, { + json: true, headers: { Referer: SESSION_URL, + Origin: SESSION_URL, "User-Agent": USER_AGENT } }) .then(body => { - qtv = /var qtv = "([^\"]+)";/.exec(body)[1] - qtk = /var qtk = "([^\"]+)";/.exec(body)[1] + qtv = body.qtv + qtk = body.qtk }) .then(requestTranslation) };