mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2026-01-17 13:50:36 +00:00
fix
This commit is contained in:
parent
646bb6bd79
commit
1b7ce8e7a5
@ -1,17 +1,29 @@
|
|||||||
const https = require('node:https');
|
const https = require('node:https');
|
||||||
export async function HttpGetWithCookies(url: string) {
|
export async function HttpGetWithCookies(url: string): Promise<Map<string, string>> {
|
||||||
const req = https.get(url, (res: any) => {
|
return new Promise((resolve, reject) => {
|
||||||
res.on('data', (data: any) => {
|
let result: Map<string, string> = new Map<string, string>();
|
||||||
});
|
const req = https.get(url, (res: any) => {
|
||||||
res.on('end', () => {
|
res.on('data', (data: any) => {
|
||||||
const responseCookies = res.headers['set-cookie'];
|
});
|
||||||
console.log('获取到的 cookies:', responseCookies);
|
res.on('end', () => {
|
||||||
console.log(res.headers)
|
try {
|
||||||
});
|
const responseCookies = res.headers['set-cookie'];
|
||||||
});
|
for (const line of responseCookies) {
|
||||||
|
const parts = line.split(';');
|
||||||
|
const [key, value] = parts[0].split('=');
|
||||||
|
result.set(key, value);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
}
|
||||||
|
resolve(result);
|
||||||
|
|
||||||
req.on('error', (error: any) => {
|
});
|
||||||
// console.log(error)
|
});
|
||||||
|
req.on('error', (error: any) => {
|
||||||
|
resolve(result);
|
||||||
|
// console.log(error)
|
||||||
|
})
|
||||||
|
req.end()
|
||||||
})
|
})
|
||||||
req.end()
|
|
||||||
}
|
}
|
||||||
@ -4,13 +4,18 @@ import { friends } from '../../../common/data';
|
|||||||
import BaseAction from '../BaseAction';
|
import BaseAction from '../BaseAction';
|
||||||
import { ActionName } from '../types';
|
import { ActionName } from '../types';
|
||||||
import { NTQQUserApi } from '@/core/apis';
|
import { NTQQUserApi } from '@/core/apis';
|
||||||
|
interface Payload {
|
||||||
|
domain: string
|
||||||
export class GetCookies extends BaseAction<null, null> {
|
}
|
||||||
|
interface Response {
|
||||||
|
Pskey: Object;
|
||||||
|
Skey: string;
|
||||||
|
}
|
||||||
|
export class GetCookies extends BaseAction<Payload, Response> {
|
||||||
actionName = ActionName.GetCookies;
|
actionName = ActionName.GetCookies;
|
||||||
|
|
||||||
protected async _handle(payload: null) {
|
protected async _handle(payload: Payload) {
|
||||||
NTQQUserApi.getSkey();
|
let _Skey = await NTQQUserApi.getSkey();
|
||||||
// 取Skey
|
// 取Skey
|
||||||
// 先NodeIKernelTicketService.forceFetchClientKey('')
|
// 先NodeIKernelTicketService.forceFetchClientKey('')
|
||||||
// 返回值
|
// 返回值
|
||||||
@ -24,17 +29,19 @@ export class GetCookies extends BaseAction<null, null> {
|
|||||||
// }
|
// }
|
||||||
// request https://ssl.ptlogin2.qq.com/jump?ptlang=1033&clientuin=1627126029&clientkey=key
|
// request https://ssl.ptlogin2.qq.com/jump?ptlang=1033&clientuin=1627126029&clientkey=key
|
||||||
// &u1=https%3A%2F%2Fh5.qzone.qq.com%2Fqqnt%2Fqzoneinpcqq%2Ffriend%3Frefresh%3D0%26clientuin%3D0%26darkMode%3D0&keyindex=keyIndex
|
// &u1=https%3A%2F%2Fh5.qzone.qq.com%2Fqqnt%2Fqzoneinpcqq%2Ffriend%3Frefresh%3D0%26clientuin%3D0%26darkMode%3D0&keyindex=keyIndex
|
||||||
// 取Location
|
let _PSkey = await NTQQUserApi.getPSkey([payload.domain]);
|
||||||
// onBeforeSendHeaders info {"sec-ch-ua":"\\"Not_A Brand\\";v=\\"8\\", \\"Chromium\\";v=\\"120\\"","Accept":"application/json, text/plain, */*","sec-ch-ua-mobile":"?0","User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) QQ/9.9.9-23159 Chrome/120.0.6099.56 Electron/28.0.0 Safari/537.36 OS/win32,x64,10.0.26100,Windows 10 Pro","sec-ch-ua-platform":"\\"Windows\\"","Origin":"https://h5.qzone.qq.com","Sec-Fetch-Site":"cross-site","Sec-Fetch-Mode":"cors","Sec-Fetch-Dest":"empty","Accept-Encoding":"gzip, deflate, br","Accept-Language":"zh-CN","referer":"https://h5.qzone.qq.com","Referer":"https://h5.qzone.qq.com","origin":"https://h5.qzone.qq.com"}
|
|
||||||
// 取Pskey
|
// 取Pskey
|
||||||
// NodeIKernelTipOffService.getPskey([ 'qun.qq.com' ], true )
|
// NodeIKernelTipOffService.getPskey([ 'qun.qq.com' ], true )
|
||||||
// {
|
// {
|
||||||
// result: 0,
|
// domainPskeyMap: 0,
|
||||||
// errMsg: 'success',
|
// errMsg: 'success',
|
||||||
// domainPskeyMap: Map(1) {
|
// domainPskeyMap: Map(1) {
|
||||||
// 'qun.qq.com' => 'pskey'
|
// 'qun.qq.com' => 'pskey'
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
return null;
|
if (!_PSkey || !_Skey) {
|
||||||
|
throw new Error("获取Cookies失败");
|
||||||
|
}
|
||||||
|
return { Pskey: _PSkey, Skey: _Skey };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user