9b395f5cc3
E2E Headed Chrome / e2e-headed (macos-15) (push) Has been cancelled
E2E Headed Chrome / e2e-headed (ubuntu-latest) (push) Has been cancelled
E2E Headed Chrome / e2e-headed (windows-latest) (push) Has been cancelled
CI / build (macos-latest) (push) Has been cancelled
CI / build (ubuntu-latest) (push) Has been cancelled
CI / build (windows-latest) (push) Has been cancelled
CI / unit-test (push) Has been cancelled
CI / bun-test (push) Has been cancelled
CI / adapter-test (push) Has been cancelled
CI / smoke-test (macos-latest) (push) Has been cancelled
CI / smoke-test (ubuntu-latest) (push) Has been cancelled
Security Audit / audit (push) Has been cancelled
Build Chrome Extension / build (push) Has been cancelled
Trigger Website Rebuild (Docs Updated) / dispatch (push) Has been cancelled
56 lines
2.0 KiB
JavaScript
56 lines
2.0 KiB
JavaScript
/**
|
|
* Xiaohongshu Creator Profile — creator account info and growth status.
|
|
*
|
|
* Uses the creator.xiaohongshu.com internal API (cookie auth).
|
|
* Returns follower/following counts, total likes+collects, and
|
|
* creator level growth info.
|
|
*
|
|
* Requires: logged into creator.xiaohongshu.com in Chrome.
|
|
*/
|
|
import { cli, Strategy } from '@jackwener/opencli/registry';
|
|
cli({
|
|
site: 'xiaohongshu',
|
|
name: 'creator-profile',
|
|
access: 'read',
|
|
description: '小红书创作者账号信息 (粉丝/关注/获赞/成长等级)',
|
|
domain: 'creator.xiaohongshu.com',
|
|
strategy: Strategy.COOKIE,
|
|
browser: true,
|
|
navigateBefore: false,
|
|
args: [],
|
|
columns: ['field', 'value'],
|
|
func: async (page, _kwargs) => {
|
|
await page.goto('https://creator.xiaohongshu.com/new/home');
|
|
const data = await page.evaluate(`
|
|
async () => {
|
|
try {
|
|
const resp = await fetch('/api/galaxy/creator/home/personal_info', {
|
|
credentials: 'include',
|
|
});
|
|
if (!resp.ok) return { error: 'HTTP ' + resp.status };
|
|
return await resp.json();
|
|
} catch (e) {
|
|
return { error: e.message };
|
|
}
|
|
}
|
|
`);
|
|
if (data?.error) {
|
|
throw new Error(data.error + '. Are you logged into creator.xiaohongshu.com?');
|
|
}
|
|
if (!data?.data) {
|
|
throw new Error('Unexpected response structure');
|
|
}
|
|
const d = data.data;
|
|
const grow = d.grow_info || {};
|
|
return [
|
|
{ field: 'Name', value: d.name ?? '' },
|
|
{ field: 'Followers', value: d.fans_count ?? 0 },
|
|
{ field: 'Following', value: d.follow_count ?? 0 },
|
|
{ field: 'Likes & Collects', value: d.faved_count ?? 0 },
|
|
{ field: 'Creator Level', value: grow.level ?? 0 },
|
|
{ field: 'Level Progress', value: `${grow.fans_count ?? 0}/${grow.max_fans_count ?? 0} fans` },
|
|
{ field: 'Bio', value: (d.personal_desc ?? '').replace(/\\n/g, ' | ') },
|
|
];
|
|
},
|
|
});
|