generated from tailored/router-db-template
temp
This commit is contained in:
14
packages/xhs/src/test/command.ts
Normal file
14
packages/xhs/src/test/command.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { program } from 'commander';
|
||||
import './query/get-components.ts';
|
||||
import './query/get-note.ts';
|
||||
import './query/mention.ts'
|
||||
import './query/unread.ts';
|
||||
import './query/get-userinfo.ts';
|
||||
import './query/get-connections.ts'
|
||||
program
|
||||
.command('test')
|
||||
.description('test command')
|
||||
.action(() => {
|
||||
console.log('test command');
|
||||
});
|
||||
program.parse(process.argv);
|
||||
@@ -1,4 +1,8 @@
|
||||
import { XhsClient } from '../index.ts';
|
||||
export const cookie = "a1=19686f83a65uiloc0y7wv79une457hsjh5lt00dpe40000147626;abRequestId=0a794332-4561-5f49-93f7-780b8b028e1f;access-token-creator.xiaohongshu.com=customer.creator.AT-68c517498636784561614544frjvxzj7yu8iewie;agora_session=6a0031373435393132333637323735343733393437313634000000000000;customerClientId=536706778174172;galaxy_creator_session_id=OhpHDDSoADhNEhnH5LLnQpletFLApu1fd91f;galaxy.creator.beaker.session.id=1745912429847011598150;gid=yjKqYfK0qDyYyj2DDSqd4ujxyW9kvxIuT62ddkMWhElyuxq8yDd6hl888q2WYy88j8i80yYD;loadts=1746020512562;sec_poison_id=441c932e-a6ac-4d8d-97ae-beb14adb1929;unread={%22ub%22:%2267eaf1fe000000001202c3ea%22%2C%22ue%22:%226803aa37000000001c0319d8%22%2C%22uc%22:35};web_session=040069b2e9c511ca302086ca253a4bde8b1cd1;webBuild=4.62.3;webId=97e5f097499594cad49aa0bd1a8ed83f;websectiga=3633fe24d49c7dd0eb923edc8205740f10fdb18b25d424d2a2322c6196d2a4ad;x-user-id-creator.xiaohongshu.com=639d86590000000026006076;xsecappid=xhs-pc-web;acw_tc=0a00df6217460205042195762e721fba339a0dbe8e4738b961a5ff15e74619;"
|
||||
import { XhsClient, xhsServices } from '../index.ts';
|
||||
import { program } from 'commander';
|
||||
export const cookie =
|
||||
'a1=1968ba02ff4xrt6hfrzdiz7ubs82j9y3vx11vfw9c40000317680;abRequestId=0a794332-4561-5f49-93f7-780b8b028e1f;access-token-creator.xiaohongshu.com=customer.creator.AT-68c517498636784561614544frjvxzj7yu8iewie;agora_session=6a0031373435393132333637323735343733393437313634000000000000;customerClientId=536706778174172;galaxy_creator_session_id=OhpHDDSoADhNEhnH5LLnQpletFLApu1fd91f;galaxy.creator.beaker.session.id=1745912429847011598150;gid=yjKqYfK0qDyYyj2DDSqd4ujxyW9kvxIuT62ddkMWhElyuxq8yDd6hl888q2WYy88j8i80yYD;loadts=1746020512562;sec_poison_id=441c932e-a6ac-4d8d-97ae-beb14adb1929;unread={%22ub%22:%2267eaf1fe000000001202c3ea%22%2C%22ue%22:%226803aa37000000001c0319d8%22%2C%22uc%22:35};web_session=040069b2e9c511ca302086ca253a4bde8b1cd1;webBuild=4.62.3;webId=97e5f097499594cad49aa0bd1a8ed83f;websectiga=3633fe24d49c7dd0eb923edc8205740f10fdb18b25d424d2a2322c6196d2a4ad;x-user-id-creator.xiaohongshu.com=639d86590000000026006076;xsecappid=xhs-pc-web;acw_tc=0a00df6217460205042195762e721fba339a0dbe8e4738b961a5ff15e74619;';
|
||||
|
||||
export const client = new XhsClient({ cookie } as any);
|
||||
|
||||
export { program, xhsServices };
|
||||
|
||||
14
packages/xhs/src/test/query/get-components.ts
Normal file
14
packages/xhs/src/test/query/get-components.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { client } from '../common.ts';
|
||||
import { program } from 'commander';
|
||||
|
||||
program
|
||||
.command('get-commonents')
|
||||
.description('get commonents')
|
||||
.action(async () => {
|
||||
const res = await client.getNoteComments('6810d722000000002100f139', '', {
|
||||
//
|
||||
xsec_token: 'LBEqTFigLzp41AdwQ-E3hbQScnvrx2flLgHElHpQ8zHWc=',
|
||||
top_comment_id: '6810e7d80000000012020c7a'
|
||||
});
|
||||
console.log(res);
|
||||
});
|
||||
14
packages/xhs/src/test/query/get-connections.ts
Normal file
14
packages/xhs/src/test/query/get-connections.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { xhsServices, program } from '../common.ts';
|
||||
import util from 'node:util';
|
||||
const getConnections = async () => {
|
||||
const client = xhsServices.getClient();
|
||||
const res = await client.getFollowNotifications(10, '');
|
||||
console.log(util.inspect(res, { depth: null, colors: true }));
|
||||
};
|
||||
|
||||
program
|
||||
.command('get-connections')
|
||||
.description('获取关注通知')
|
||||
.action(async () => {
|
||||
await getConnections();
|
||||
});
|
||||
33
packages/xhs/src/test/query/get-note.ts
Normal file
33
packages/xhs/src/test/query/get-note.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { client } from '../common.ts';
|
||||
import { program } from 'commander';
|
||||
|
||||
// client.getNoteComments()
|
||||
|
||||
// client.getNoteByIdFromHtml('67dcc34e000000000602a8eb', 'ABuYS8Xb1o08DlRmMLIabdqnW0OKnLR9nMpDGq5bVRdvk').then((res) => {
|
||||
// console.log(res);
|
||||
// });
|
||||
const getNoteById = async () => {
|
||||
client.getNoteById('67dcc34e000000000602a8eb', 'ABuYS8Xb1o08DlRmMLIabdqnW0OKnLR9nMpDGq5bVRdvk').then((res) => {
|
||||
console.log(res);
|
||||
});
|
||||
};
|
||||
const getNote = async () => {
|
||||
const id = '6810d722000000002100f139';
|
||||
const x = 'LBEqTFigLzp41AdwQ-E3hbQScnvrx2flLgHElHpQ8zHWc=';
|
||||
client.getNoteByIdFromHtml(id, x).then((res) => {
|
||||
console.log(res);
|
||||
});
|
||||
};
|
||||
program
|
||||
.command('get-note')
|
||||
.description('get note')
|
||||
.action(async () => {
|
||||
getNote();
|
||||
});
|
||||
|
||||
program
|
||||
.command('get-note-by-id')
|
||||
.description('get note by id')
|
||||
.action(async () => {
|
||||
getNoteById();
|
||||
});
|
||||
12
packages/xhs/src/test/query/get-sign.ts
Normal file
12
packages/xhs/src/test/query/get-sign.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { client, program } from '../common.ts';
|
||||
|
||||
const getSign = async () => {
|
||||
const uri = '/api/sns/web/v1/you/mentions';
|
||||
const data = null;
|
||||
const config = { headers: {} };
|
||||
const res = await client.sign(uri, data, config);
|
||||
console.log('getSign', res);
|
||||
};
|
||||
// getSign();
|
||||
|
||||
program.command('sign').description('get sign').action(getSign);
|
||||
21
packages/xhs/src/test/query/get-userinfo.ts
Normal file
21
packages/xhs/src/test/query/get-userinfo.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { client, program } from '../common.ts';
|
||||
|
||||
program
|
||||
.command('get-userinfo')
|
||||
.description('获取用户信息')
|
||||
.action(async () => {
|
||||
const res = await client.getSelfInfoV2();
|
||||
console.log(res);
|
||||
});
|
||||
|
||||
const getUserById = async (userId: string) => {
|
||||
const res = await client.getUserInfoFromHtml(userId);
|
||||
console.log(res);
|
||||
};
|
||||
|
||||
program
|
||||
.command('get-userinfo-by-id <userId>')
|
||||
.description('获取用户信息')
|
||||
.action(async (userId: string) => {
|
||||
await getUserById(userId);
|
||||
});
|
||||
@@ -1,15 +0,0 @@
|
||||
import { client } from '../common.ts';
|
||||
|
||||
// client.getNoteComments()
|
||||
|
||||
// client.getNoteById('67dcc34e000000000602a8eb', 'ABuYS8Xb1o08DlRmMLIabdqnW0OKnLR9nMpDGq5bVRdvk').then((res) => {
|
||||
// console.log(res);
|
||||
// });
|
||||
// client.getNoteByIdFromHtml('67dcc34e000000000602a8eb', 'ABuYS8Xb1o08DlRmMLIabdqnW0OKnLR9nMpDGq5bVRdvk').then((res) => {
|
||||
// console.log(res);
|
||||
// });
|
||||
const id = '6810d722000000002100f139';
|
||||
const x = 'LBEqTFigLzp41AdwQ-E3hbQScnvrx2flLgHElHpQ8zHWc=';
|
||||
client.getNoteByIdFromHtml(id, x).then((res) => {
|
||||
console.log(res);
|
||||
});
|
||||
@@ -1,5 +0,0 @@
|
||||
import { client } from '../common.ts';
|
||||
|
||||
client.getSelfInfoV2().then((res) => {
|
||||
console.log(res);
|
||||
});
|
||||
26
packages/xhs/src/test/query/mention.ts
Normal file
26
packages/xhs/src/test/query/mention.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { client, program } from '../common.ts';
|
||||
import util from 'node:util';
|
||||
const getMentions = async () => {
|
||||
try {
|
||||
const res = await client.getMention();
|
||||
if (res.code === 0) {
|
||||
console.log('getMentionNotifications', util.inspect(res, { depth: 10 }));
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('error');
|
||||
}
|
||||
};
|
||||
|
||||
program.command('mention').description('get mention notifications').action(getMentions);
|
||||
|
||||
const getTestMentionNote = async () => {
|
||||
const id = '68136dab0000000007034c46';
|
||||
const xsec_token = 'LByEmonX8WfJ9ebpAowVbOZcNgtJAAC8K2zx5Rmr_9Q7Y=';
|
||||
const title = '在笔记中@了你';
|
||||
const type = 'mention/item';
|
||||
const track_type = '2';
|
||||
const note = await client.getNoteByIdFromHtml(id, xsec_token);
|
||||
console.log('note', note);
|
||||
};
|
||||
|
||||
program.command('test-mention').description('get mention note').action(getTestMentionNote);
|
||||
@@ -1,5 +1,9 @@
|
||||
import { client } from '../common.ts';
|
||||
import { client, program } from '../common.ts';
|
||||
|
||||
client.getUnread().then((res) => {
|
||||
console.log(res);
|
||||
});
|
||||
const getUnread = () => {
|
||||
client.getUnread().then((res) => {
|
||||
console.log(res);
|
||||
});
|
||||
};
|
||||
|
||||
program.command('unread').description('获取未读消息').action(getUnread);
|
||||
|
||||
6
packages/xhs/src/test/run/mention.ts
Normal file
6
packages/xhs/src/test/run/mention.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import { app } from '@/index.ts';
|
||||
|
||||
app.parse({
|
||||
path: 'mention',
|
||||
key: 'run-unread-task',
|
||||
});
|
||||
Reference in New Issue
Block a user