Mcp.env
Overview
What is mcp_fetch_xhs_post?
The ### mcp_fetch_xhs_post is a public repository created by the user ### chaseSpace on GitHub. This repository is designed to fetch posts from the XHS (Xiaohongshu) platform, which is a popular social media and e-commerce platform in China. The repository likely contains scripts or tools that allow users to extract, analyze, or interact with posts from XHS, making it a valuable resource for developers and data analysts interested in social media data.
Features of mcp_fetch_xhs_post
- Public Access: The repository is publicly accessible, allowing anyone to view, clone, or contribute to the project.
- Data Fetching: It provides functionalities to fetch posts from the XHS platform, which can be useful for data analysis, research, or application development.
- Open Source: Being an open-source project, users can contribute to its development, report issues, or suggest enhancements.
- Community Engagement: Users can star the repository to show appreciation, fork it to create their own versions, or follow updates through notifications.
How to Use mcp_fetch_xhs_post
-
Clone the Repository: Use Git to clone the repository to your local machine.
git clone https://github.com/chaseSpace/mcp_fetch_xhs_post.git
-
Install Dependencies: Navigate to the cloned directory and install any required dependencies, typically listed in a
requirements.txt
file or similar.cd mcp_fetch_xhs_post pip install -r requirements.txt
-
Run the Fetching Script: Execute the main script to start fetching posts from XHS.
python fetch_xhs_posts.py
-
Analyze the Data: Once the data is fetched, you can analyze it using your preferred data analysis tools or libraries.
Frequently Asked Questions
What programming language is used in mcp_fetch_xhs_post?
The repository is primarily written in Python, which is commonly used for data fetching and analysis tasks.
Can I contribute to the mcp_fetch_xhs_post repository?
Yes, contributions are welcome! You can fork the repository, make your changes, and submit a pull request for review.
Is there any documentation available for mcp_fetch_xhs_post?
Documentation may be available within the repository itself, typically in a README.md
file or a docs
directory. Always check there for usage instructions and guidelines.
How can I report issues or bugs in the repository?
You can report issues by navigating to the "Issues" tab of the repository on GitHub and submitting a new issue with details about the problem you encountered.
Are there any prerequisites to use mcp_fetch_xhs_post?
You may need to have Python installed on your machine along with any necessary libraries specified in the repository's documentation.
Details
Python-MCP-Server:小红书热帖获取
本项目基于 FastMCP SDK 开发,功能是根据指定“关键词”获取小红书的热帖数据,默认获取5~ 10篇(参数控制),不支持翻页获取。
1. Tools
- fetch_xhs_hot_post:从小红书获取爆款帖子数据
- 具体包括每篇帖子的标题、内容、发布时间、标签等数据,请查看
model.py
中的Post
class了解更多。
- 具体包括每篇帖子的标题、内容、发布时间、标签等数据,请查看
2. 准备
2.1 环境要求
- Python 3.12+
- Chrome浏览器,Centos 安装参考这里
2.2 外部环境变量
由于目标网站需要登录后才可以搜索内容,因为本项目使用了钉钉来接收登录二维码,请先在钉钉群中添加机器人(安全设置选择加签), 并获取必要信息作为环境变量注入环境,如下示例:
### mcp.env
DINGTALK_WEBHOOK_URI=https://oapi.dingtalk.com/robot/send?access_token=YOUR_TOKEN
DINGTALK_SECRET=YOUR_SECRET
将上述环境变量放入项目根目录下的mcp.env
文件(自行创建)中即可。
3. 安装运行
注:本项目并未通过 pypi 进行分发,目前仅支持本地部署运行。
- 首先Clone本项目,然后使用uv命令安装依赖:
### 若未安装uv,可通过pip等方式安装
cd mcp_fetch_xhs_post
source .venv/Scripts/activate # 激活venv。若是windows cmd环境,则执行 .\.venv\Scripts\activate.bat
uv sync
- 启动:
uv run main.py
4. 添加MCP Server
项目启动后,在所使用的MCP Client添加一个MCP Server,关键配置如下
- 名称:小红书热帖获取
- 传输类型:SSE
- URL:http://127.0.0.1:9090/sse (假设在本机运行MCP Server,端口可在代码中修改)
5. 运行流程
项目启动且成功添加到MCP Client后,就可以开始使用了。
第一次运行时,由于本地的Chrome浏览器可能没有登录小红书PC网站,程序会自动将用于登录的二维码发送至钉钉群中, 请进入钉钉群扫码登陆,程序将会等待30s,如超时工具会自动重试最多3次。登陆成功后,程序也会将登陆成功的消息发送至钉钉群中。 之后会开始获取数据,在启动项目的控制台输出中可以看到运行日志打印。
6. 免责声明
6.1 目的
本项目旨在提供一个教育和研究工具,用于学习和理解MCP、网络爬虫技术的实现和应用。本项目不鼓励或支持任何违反服务条款或法律法规的行为。
6.2 服务条款遵守
使用本项目前,请确保您已经阅读并理解目标网站(如小红书)的服务条款。本项目不保证对目标网站的服务条款完全兼容,使用本项目爬取数据可能违反目标网站的服务条款。
6.3 合法性
用户在使用本项目时应确保其行为符合当地法律法规及目标网站的使用政策。本项目不对因违反法律法规或服务条款而导致的任何后果承担责任。
6.4 数据使用
用户应仅将通过本项目爬取的数据用于合法和正当的目的。不得将数据用于商业目的、侵犯版权、侵犯个人隐私或其他不当用途。
6.5 风险自负
使用本项目爬取数据存在被目标网站封禁或其他形式的反爬措施的风险。用户应自行承担使用本项目可能带来的所有风险。
6.6 开源协议
本项目遵循 MIT License 开源协议。在遵循开源协议的前提下,您可以自由地使用、修改和分发本项目。
6.7 免责声明
本项目“按原样”提供,不提供任何形式的明示或暗示的保证,包括但不限于对适销性、特定用途适用性和非侵权性的保证。在任何情况下, 作者或贡献者均不对因使用本项目而产生的任何直接的、间接的、偶然的、特殊的、惩罚性的或后果性的损害负责,包括但不限于替代商品或服务的采购、 使用、数据或利润的损失,或业务中断,无论此类损害是如何引起的,也无论是否已告知可能发生此类损害的可能性。
6.8 联系方式
如果您对本项目有任何疑问或担忧,或发现本项目可能违反了法律法规或服务条款,请通过Github issue与我联系。
Server Config
{
"mcpServers": {
"mcp_fetch_xhs_post": {
"command": "仅支持本地sse部署",
"args": [],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "<YOUR_TOKEN>"
}
}
}
}