xiaohongshu-downloader
v1.0.5
Published
A simple library to scrape media and metadata from Xiaohongshu (Red Note).
Maintainers
Readme
Xiaohongshu Downloader Library
A simple JavaScript library to scrape metadata and download links from Xiaohongshu (RedNote). This library extracts detailed metadata and provides download links for videos or images.
Features
- Scrape title, category, author details, and stats.
- Extract download links for images or videos.
Installation
Install via npm:
npm install xiaohongshu-downloaderUsage
Import the Library
const { scrapeXiaohongshu } = require('xiaohongshu-downloader');Example Code
const { scrapeXiaohongshu } = require('xiaohongshu-downloader');
(async () => {
const url = 'https://www.xiaohongshu.com/explore/example-url';
const result = await scrapeXiaohongshu(url);
console.log('--- Metadata ---');
console.log(result.metadata);
console.log('--- Download Links ---');
console.log(result.download);
})();Example Output
Metadata
{
"title": "xxxxxxx",
"category": ["xxxxxxx", "xxxxxxx", "xxxxxxx"],
"stats": {
"liked": false,
"likedCount": "1万+",
"collected": false,
"collectedCount": "10+",
"commentCount": "10+",
"shareCount": "10+",
"followed": false,
"relation": "none"
},
"author": {
"userId": "652xxxxxxxxxxxx",
"nickname": "xxxxxxxxx",
"avatar": "https://sns-avatar-qc.xhscdn.com/avatar/xxxxxxxxxxxxxxxx.jpg",
"xsecToken": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}
}
// Video: http://sns-video-ak.xhscdn.com/stream/xxxxxxxxxxxxxxx.mp4Error Handling
The library will throw an error if:
- The provided URL is invalid.
- The content cannot be scraped (e.g., due to changes in the Xiaohongshu structure).
Use a try-catch block to handle errors:
try {
const result = await scrapeXiaohongshu(url);
} catch (error) {
console.error('Error:', error.message);
}License
This project is licensed under the MIT License.
