Files
Hower He d0d3b6b870 feat(route): 小红书 用户笔记 全文 (#12330)
* fix(route): 小红书 用户笔记(全文抓取)

* fixed package.json's semver prefix character

* fixed conditions for user page response

* fixed timed out issue when getting full text

* removed the capability to get full text

* added full text feature for notes

* added filter for unnecessary resources requested

* Switched to a concise way to get JSON from HTML

* to bypass the null checked warning from DeepScan

* added note full text to cache

* added more readable error messages

* moved full text feature under a new parameter

* Update maintainer format

* Refactor the error message typing

* Refactor the error message typing

* Refactor error message typing

* Refactor the usage of `tryGet` for expire time

* Close the user page earlier to release resouces

---------
2023-05-15 22:14:55 +08:00

17 lines
531 B
JavaScript

const { getNotes, formatText, formatNote } = require('./util');
module.exports = async (ctx) => {
const userId = ctx.params.user_id;
const url = `https://www.xiaohongshu.com/user/profile/${userId}`;
const { user, notes } = await getNotes(url, ctx.cache);
ctx.state.data = {
title: `${user.nickname} - 笔记 • 小红书 / RED`,
description: formatText(user.desc),
image: user.imageb || user.images,
link: url,
item: notes.map((item) => formatNote(url, item)),
};
};