goesByhc/cn-scraper-mcp

🔎 Search & Data Extraction
0 Views
0 Installs

🐍 🏠 - MCP server that lets AI agents search and extract data from major Chinese internet platforms including Taobao, JD, Xiaohongshu, Zhihu, Weibo, Bilibili, ZSXQ, Douban, and Dianping, with local-first cookie storage and CDP-assisted login.

Quick Install

One-Click IDE Configuration
claude_desktop_config.json
{
  "mcpServers": {
    "goesbyhc-cn-scraper-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "goesbyhc-cn-scraper-mcp"
      ]
    }
  }
}
Or

Using an AI coding agent (Claude Code, Cursor, etc.)? Copy a ready-made prompt that tells it to fetch the setup instructions and install this server for you.

Documentation Overview

CN Scraper MCP 图标

CN Scraper MCP

让 AI Agent 直接搜索中国互联网——淘宝、京东、小红书、知乎、微博、B站、知识星球……不再被反爬墙挡住。

Python 3.11+ MCP compatible MIT License CI


这是什么

每个 AI Agent(Codex、Claude Code、Cursor、Trae)都能搜网页,但中文平台通常需要登录态、浏览器环境或平台专用参数:

  • 淘宝:需要浏览器一致的网络指纹和登录 Cookie
  • 京东:依赖已登录的本地浏览器环境
  • 小红书:需要住宅 IP、本地浏览器和搜索结果中的访问参数
  • 知乎:游客搜索已关闭,全部 API 需要登录态
  • 拼多多:平台限制严格,目前不推荐使用
  • 微博:搜索 API 需要登录态(SUB token),热搜游客即可访问
  • 抖音:需要浏览器登录并可能人工处理验证码
  • B站:搜索、热门、视频详情和评论可直接使用公开 API
  • 豆瓣:条目搜索、条目详情和短评/影评
  • 大众点评:商户搜索、商户详情和用户评价
  • 知识星球:付费社群,内容藏在 cookie 认证的 REST API 后面

这个项目就是把踩了好几个月的坑打包成一个 MCP Server——你的 Agent 一句话就能搜:taobao_search("儿童学习桌")

安全与隐私

cn-scraper-mcp 在你的电脑上本地运行,不需要把 Cookie、账号密码或浏览器 Profile 上传到任何中转服务器:

  • Cookie 默认保存在 ~/.cn-scraper-cookies/,京东登录态保存在本地 Chrome Profile。
  • 登录过程直接发生在平台官方页面,软件不会读取或保存你的账号密码。
  • Cookie 值不会写入日志,也不会通过 MCP 工具结果返回给 Agent;工具只返回状态、字段名和本地路径等非敏感信息。
  • 发起抓取或在线登录验证时,凭证只会发送给对应平台域名。
  • 代码完全开源,所有凭证处理流程都可以审查。

建议仍像保护浏览器登录态一样保护本机账号:不要分享 Cookie 文件,不要把凭证提交到 Git,并限制本地文件的访问权限。


平台支持

电商

平台方式无需浏览器限制稳定性
淘宝/Tmallcurl_cffi + MTOP 签名宽松¹✅ 稳定
京东/JDChrome CDP headful需 Chrome中等✅ 稳定²
拼多多/PDDChrome CDP + iPhone UA需 Chrome单次搜索限制³⚠️ 不推荐

¹ 淘宝无硬性限流,但平台可能随时收紧,不建议高频批量抓取。 ² 京东由本地 Chrome 生成登录态和动态签名,工具读取结构化 API 响应;通过 guided_login("jd") 可自动初始化持久化 Profile。 ³ 拼多多每个浏览器会话仅放行第一次搜索,之后永久"系统繁忙"。单次搜索结果零实用价值,引擎代码保留但不推荐使用。

内容社区

平台方式无需浏览器限制稳定性
小红书/XHS本地 Chrome CDP + cookie需 Chrome中等⁴✅ 稳定
知乎/ZhihuREST API v4正常✅ 稳定
知识星球/ZSXQREST API v2正常✅ 稳定
微博/WeiboREST API正常✅ 稳定
抖音/Douyin ⚠️Chrome CDP + 验证码轮询需 Chrome实验性⁵⚠️ 实验性
B站/Bilibili公开 Web API建议低频调用✅ 稳定
豆瓣/Douban移动端 JSON API搜索可能触发风控⚠️ 依会话
大众点评/Dianping公开网页解析可能触发页面风控⚠️ 依页面结构

⁴ 小红书只允许住宅 IP——云浏览器/数据中心 IP 直接封。必须用本地 Chrome。 ⁵ 抖音搜索需要登录态 + 手动过滑块验证码。支持 120s 等待用户手动验证,通过后自动抓取。guided_login("douyin") 可引导登录。

快速开始

安装

pip install cn-scraper-mcp

也可以从源码安装开发版本:

git clone https://github.com/goesByhc/cn-scraper-mcp.git
cd cn-scraper-mcp
pip install .

推荐:CDP 自动登录并保存 Cookie

安装并连接 MCP 后,直接让 Agent 调用:

guided_login(platform="weibo")

它会打开本地 Chrome 并进入平台官方登录页。你自己扫码或输入密码后,工具通过 CDP 自动读取完整 Cookie(包括 JavaScript 无法读取的 HttpOnly Cookie),再保存到本机 ~/.cn-scraper-cookies/。京东则保存到本地持久化 Chrome Profile。

这是推荐方式,因为它不会要求你复制 Cookie,不容易漏掉关键字段,也更适合 Cookie 过期后的重新登录。可用平台名包括 taobaojdxiaohongshuzhihuweibozsxqdouyinpdddoubandianping

已有通过远程调试端口启动且登录完成的 Chrome 时,也可以调用:

harvest_cookies(platform="weibo")

启动

cn-scraper-mcp
# 或: python -m cn_scraper_mcp.server

Docker

容器内预装 Chromium,无需本地浏览器:

docker build -t cn-scraper-mcp .
docker run -i --rm \
  -v ~/.cn-scraper-cookies:/root/.cn-scraper-cookies \
  -v ~/.jd_login_profile:/root/.jd_login_profile \
  cn-scraper-mcp

远程服务器部署可以切换到 HTTP transport,通过 IP + 端口 连接:

docker pull ghcr.io/goesbyhc/cn-scraper-mcp:latest
docker run -d --name cn-scraper-mcp \
  -p 8000:8000 \
  -e CN_SCRAPER_TRANSPORT=http \
  -e CN_SCRAPER_HOST=0.0.0.0 \
  -e CN_SCRAPER_PORT=8000 \
  -e CN_SCRAPER_PATH=/mcp \
  -v ~/.cn-scraper-cookies:/root/.cn-scraper-cookies \
  -v ~/.jd_login_profile:/root/.jd_login_profile \
  ghcr.io/goesbyhc/cn-scraper-mcp:latest

远程 MCP endpoint:

http://<server-ip>:8000/mcp

也可以使用 Docker Compose:

docker compose --profile remote up -d cn-scraper-http

可用环境变量:

变量默认值说明
CN_SCRAPER_TRANSPORTstdiostdiohttpsse,也接受 streamable-http 作为 http 别名
CN_SCRAPER_HOST0.0.0.0HTTP/SSE 模式监听地址
CN_SCRAPER_PORT8000HTTP/SSE 模式监听端口
CN_SCRAPER_PATH/mcpHTTP/SSE MCP endpoint 路径

远程 HTTP 模式会让 MCP 工具通过网络访问本机 Cookie/Profile 目录,请勿直接裸露公网端口。建议放在内网、VPN、防火墙白名单或带鉴权的反向代理后面。小红书、京东、抖音等依赖本地浏览器、住宅 IP 或人工验证码的平台,在远程服务器上的稳定性取决于服务器网络与图形环境。

当平台要求人工处理登录、验证码或风控页时,工具会返回统一的 ACTION_REQUIRED 结构,并在 action_required 字段中说明平台、原因、处理动作、处理链接和建议重试的工具。当前抖音验证码已接入该结构;远程 Docker 场景下仍需要你通过可见浏览器或后续 noVNC 网页完成验证。

Agent 集成配置:

# Codex ~/.codex/config.toml
[mcp_servers.cn-scraper]
command = "docker"
args = ["run", "-i", "--rm",
  "-v", "/本机绝对路径/.cn-scraper-cookies:/root/.cn-scraper-cookies",
  "-v", "/本机绝对路径/.jd_login_profile:/root/.jd_login_profile",
  "cn-scraper-mcp"]

请把 /本机绝对路径/ 替换为真实路径;MCP 客户端直接启动进程时不会替你展开 ~

Docker 镜像内置 Chromium + --no-sandbox。京东 headful 模式如需 Xvfb,设置环境变量 XVFB_WRAPPER=1。小红书仍需住宅 IP——数据中心 IP 会被封。


MCP 工具一览

电商搜索

工具说明
taobao_search淘宝/天猫关键词搜索 → 价格、销量、店铺
taobao_product淘宝商品详情 → 标题、价格、店铺
jd_search京东关键词搜索 → SKU、价格、商品名
jd_product京东商品详情 → 名称、价格、店铺、规格
pdd_search拼多多搜索 → 仅首次有效
pdd_product_detail拼多多商品详情 → 不限次数

内容社区

工具说明
xiaohongshu_search小红书笔记搜索 → 标题、作者、点赞、noteIdxsec_token
xiaohongshu_note小红书笔记详情 → 标题、正文、作者、标签、互动数、发布时间
xiaohongshu_comments小红书笔记首屏评论 → 评论内容、用户、点赞、时间(需要 noteId + xsec_token
zhihu_search知乎搜索 → 问题、文章
zhihu_hot_list知乎热榜
zhihu_comments知乎回答评论(支持分页)
zhihu_answer知乎回答完整正文
zhihu_question_answers知乎问题下的回答列表
weibo_search微博搜索 → 微博帖子内容
weibo_hot_list微博热搜榜
weibo_user_timeline微博用户时间线
weibo_comments微博帖子评论(支持分页)
weibo_post微博帖子完整详情
douyin_search抖音搜索 → CDP 浏览器 + 验证码轮询(⚠️ 实验性)
douyin_hot_list抖音热搜榜
douyin_video抖音视频详情
douyin_comments抖音视频评论
bilibili_searchB 站视频搜索(纯 HTTP,无需登录)
bilibili_popularB 站热门视频榜
bilibili_videoB 站视频详情及互动统计
bilibili_commentsB 站视频一级评论(支持分页)
douban_search豆瓣书籍、电影、音乐等条目搜索
douban_subject豆瓣条目详情
douban_reviews豆瓣条目短评/影评
dianping_search大众点评商户搜索
dianping_shop大众点评商户详情
dianping_reviews大众点评商户评价
zsxq_topics知识星球付费社群帖子
zsxq_article知识星球文章全文

Cookie 管理

工具说明
check_cookies检查所有平台 Cookie 状态
verify_login在线验证知乎、微博、知识星球、抖音登录态;不支持的平台明确返回 unsupported
diagnose环境诊断——依赖版本、浏览器、CDP 端口
harvest_cookiesCDP 自动收割 Cookie(包括 HttpOnly)
guided_login引导登录——自动打开浏览器 → 你扫码 → 登录后自动收割 Cookie

MCP 客户端配置

Codex

~/.codex/config.toml

[mcp_servers.cn-scraper]
command = "cn-scraper-mcp"
args = []

保存后可用 codex mcp list 检查连接状态。

Claude Code / Cursor / Reasonix

这三个客户端都支持标准的 mcpServers JSON:

  • Claude Code:项目根目录 .mcp.json
  • Cursor:全局 ~/.cursor/mcp.json,或项目目录 .cursor/mcp.json
  • Reasonix:项目根目录 .mcp.json
{
  "mcpServers": {
    "cn-scraper": {
      "command": "cn-scraper-mcp",
      "args": []
    }
  }
}

Trae

Trae 不同版本的配置文件位置可能不同。建议在设置中的 MCP 管理界面添加本地 stdio Server:名称填写 cn-scraper,命令填写 cn-scraper-mcp,参数留空。

如果客户端提示找不到命令,先用 where cn-scraper-mcp(Windows)或 which cn-scraper-mcp(macOS/Linux)找到完整路径,再把 command 替换为该路径。


更多文档

  • 架构设计:职责边界、平台契约和 Agent 开发守则
  • 开发规范:环境、编码、测试和 Review 要求

常见问题

Q: 使用这个软件安全吗? 软件在你的电脑上本地运行,不经过项目方的中转服务器。Cookie 和浏览器 Profile 保存在本机,Cookie 值不会写入日志或通过 MCP 返回给 Agent;需要访问平台时,凭证只发送给对应的平台域名。

Q: 软件会读取或保存账号密码吗? 不会。登录发生在平台官方页面,由你自己扫码或输入密码;工具只在登录完成后通过 CDP 保存浏览器产生的 Cookie。

Q: Cookie 保存在什么地方? Cookie 默认保存在 ~/.cn-scraper-cookies/,京东使用本地持久化 Chrome Profile。请像保护已登录浏览器一样保护这些文件,不要分享或提交到 Git。

Q: 怎么初始化 Cookie 最方便?guided_login("平台名") 工具。它会自动打开 Chrome → 导航到登录页 → 等你扫码/输密码 → 登录后自动收割 Cookie 并保存。

Q: 合法吗? 仅用于学习和研究目的。批量抓取可能违反平台服务条款。风险自负。切勿用于垃圾信息、DDoS 或商业级大规模抓取。


许可证

MIT — 详见 LICENSE

支持项目

如果这个项目帮你节省了时间,可以请作者喝杯咖啡:

微信赞赏码

致谢


Made with ☕ and months of frustration at Chinese platform anti-bot walls.

Related MCP Servers

linxule/mineru-mcp

📇 ☁️ - MCP server for MinerU document parsing API. Parse PDFs, images, DOCX, and PPTX with OCR (109 languages), batch processing (200 docs), page ranges, and local file upload. 73% token reduction with structured output.

🔎 Search & Data Extraction1 views
0xdaef0f/job-searchoor

📇 🏠 - An MCP server for searching job listings with filters for date, keywords, remote work options, and more.

🔎 Search & Data Extraction0 views
Aas-ee/open-webSearch

🐍 📇 ☁️ - Web search using free multi-engine search (NO API KEYS REQUIRED) — Supports Bing, Baidu, DuckDuckGo, Brave, Exa, and CSDN.

🔎 Search & Data Extraction0 views
ac3xx/mcp-servers-kagi

📇 ☁️ - Kagi search API integration

🔎 Search & Data Extraction0 views

Engagement

Views
0
Installs
0
Upvotes
0

Views and upvotes are unique per visitor network (hashed IP). Installs count copy actions.

Status

Health: Not checked yet

We have not completed a health check for this listing yet.

Last checked: 7/29/2026, 12:28:56 PM

Unclaimed listing (imported or pending owner verification). Claim it →
★ Spotlight Slot

Feature Your MCP Server

Get maximum visibility for your server across our directory, search results, and detail pages.

Spotlight Your Server

Own this project?

This directory is pre-filled from public sources. Claim via GitHub README, site badge, or DNS TXT to get the verified badge and attach your website.

Claim this listing

Promote this listing

Optional paid placement. Free listings stay free forever.

Share & Embed

Add our SVG badge (dark/light directory styles) or embeddable widget to your site.