Skip to main content

小红书搜索工具 - 基于 TikHub API

Project description

小红书搜索工具

基于 TikHub API 的小红书笔记搜索工具。

安装

pip install xiaohongshu-search

配置

设置 TikHub API Key:

export TIKHUB_API_KEY="your_api_key"

或创建 .env 文件:

TIKHUB_API_KEY=your_api_key

使用

命令行

# 基本搜索
xhs-search "美食推荐"

# 搜索并导出 JSON
xhs-search "北京旅游" -o results.json

# 搜索并导出 Excel
xhs-search "护肤心得" --excel results.xlsx

# 自动翻页获取多页数据
xhs-search "穿搭" -n 5 -o all.json

# 按点赞数排序
xhs-search "健身" --sort popularity_descending

# 只看视频笔记
xhs-search "教程" --type 视频笔记

# 只看最近一周
xhs-search "评测" --time 一周内

# 显示详细信息
xhs-search "数码" -v

Python API

from tikhub_xiaohongshu import TikHubClient

client = TikHubClient(api_key="your_api_key")

# 单页搜索
result = client.search_notes(keyword="美食推荐", page=1)
notes = result.data["notes"]

# 自动翻页
all_notes = client.search_notes_all("美食推荐", max_pages=5)

# 获取笔记详情
note = client.get_note_info(note_id="665f95200000000006005624")

选项

选项 说明 默认值
-p, --page 页码 1
-n, --max-pages 最大页数(自动翻页) 1
-o, --output 输出 JSON 文件 -
--excel 输出 Excel 文件 -
--sort 排序方式 general
--type 笔记类型 不限
--time 时间筛选 不限
-v, --verbose 显示详细信息 false

排序方式

  • general - 综合排序
  • time_descending - 最新
  • popularity_descending - 最多点赞
  • comment_descending - 最多评论
  • collect_descending - 最多收藏

笔记类型

  • 不限 - 所有类型
  • 视频笔记 - 仅视频
  • 普通笔记 - 仅图文
  • 直播笔记 - 仅直播

时间筛选

  • 不限 - 所有时间
  • 一天内 - 24 小时内
  • 一周内 - 7 天内
  • 半年内 - 6 个月内

依赖

  • Python 3.12+
  • tikhub-xiaohongshu >= 0.1.1
  • python-dotenv >= 1.1.1

可选依赖(导出 Excel):

  • pandas >= 2.2.0
  • openpyxl >= 3.0.0

许可证

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xiaohongshu_search-0.1.0.tar.gz (11.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xiaohongshu_search-0.1.0-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file xiaohongshu_search-0.1.0.tar.gz.

File metadata

  • Download URL: xiaohongshu_search-0.1.0.tar.gz
  • Upload date:
  • Size: 11.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.0

File hashes

Hashes for xiaohongshu_search-0.1.0.tar.gz
Algorithm Hash digest
SHA256 100a49e5c0255d91d2013d55697f7cffca2e993fadfcd63c65fc586b3aed56fc
MD5 d69786840cc6cb9aa8e309b64f577f2f
BLAKE2b-256 7414673390fbff47d594ed7648cf3d2b67e2c77820e443e87e445cd0b1673a7a

See more details on using hashes here.

File details

Details for the file xiaohongshu_search-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for xiaohongshu_search-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cef030571c18b33418605bd0d062eec8d76ac0ee11257d11f63f81cbe997caa2
MD5 1964ae5994830ae1c6a6beece028ec10
BLAKE2b-256 a74dd5428bbf34f63d98ad25638bc04c83c84e27af601df7d87d5505b0ed9b66

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page