VisualWebScraper
MCP server for web scraping using Playwright headless Chromium. It provides tools to fetch webpage screenshots, search article listings, and generate article briefs via local LM Studio models.
README
VisualWebScraper
基于 MCP(Model Context Protocol) 的网页抓取服务,使用 Playwright 无头 Chromium 渲染动态网页, 并可调用本地 LM Studio 大模型生成文章简报。
安装
pip install -r requirements.txt
playwright install chromium
启动
python screenshot_scraper_mcp.py
# 或
python -m webscraper.server
本地可视化操作台(Web UI)
除 MCP stdio 外,另提供基于标准库 http.server 的网页界面,无需额外依赖,
复用同一套工具层与浏览器池,供非开发者在浏览器中可视化操作。
python run_webui.py # 默认 http://127.0.0.1:8765
python run_webui.py --port 9000 # 自定义端口
打开页面后,可在「网页截图 / 文章检索 / 简报生成」三个标签页填写参数并运行; 截图工具会直接渲染返回的长图,检索与简报以文本形式展示(简报生成依赖 LM Studio)。
该 Web UI 与 MCP stdio 入口相互独立,互不影响;退出时浏览器实例同样会被释放。
MCP 客户端配置
{
"mcpServers": {
"VisualWebScraper": {
"command": "python",
"args": ["d:/BaiduSyncdisk/desktop/WebSearchMCP/screenshot_scraper_mcp.py"],
"env": {
"LMSTUDIO_BASE_URL": "http://localhost:1234/v1"
}
}
}
}
提供的工具
fetch_webpage_with_screenshot
抓取网页纯文本 + 整页长截图(PNG base64),供多模态模型做视觉分析。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
url |
string | 是 | 目标网页链接 |
search_webpage_articles
从栏目/列表页提取文章条目,按标题关键词筛选,按日期倒序输出。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
url |
string | 是 | 栏目/列表页链接 |
keyword |
string | 是 | 标题筛选关键词 |
count |
integer | 是 | 输出条数,<=0 表示全部 |
generate_webpage_brief
提取文章 → 抓取详情页正文 → 调用本地大模型逐篇生成摘要 → 输出简报。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
url |
string | 是 | 栏目/列表页链接 |
count |
integer | 是 | 生成条数 |
keyword |
string | 否 | 标题筛选关键词,留空为全部 |
summary_len |
integer | 否 | 每条摘要目标字数,默认 60 |
model |
string | 否 | LM Studio 模型名,缺省用当前加载的模型 |
三级降级链(保证任何环境下都有输出):
| 层级 | 触发条件 | 行为 |
|---|---|---|
| L1 | 首次摘要为空 | 换更直接的指令重试 |
| L2 | 仍为空 | 取正文首段作为摘要 |
| L3 | 全部条目模型调用均失败 | 判定 LM Studio 不可用,落盘 Markdown 到 briefs/ |
项目结构
webscraper/
├── config.py # 集中配置:超时、限额、环境变量
├── browser.py # Playwright 浏览器池(复用实例)
├── extractors.py # 文章提取、正文抓取、文本清洗
├── llm.py # LM Studio 调用(OpenAI 兼容接口)
├── reporter.py # 简报 Markdown 落盘与文本渲染
├── server.py # MCP 入口:handler 注册与生命周期
└── tools/
├── base.py # 工具注册表、参数校验、结果构造
├── screenshot.py # fetch_webpage_with_screenshot
├── search.py # search_webpage_articles
└── brief.py # generate_webpage_brief
站点适配
文章链接识别规则集中在 extractors.py 顶部,换站点时只需调整:
ARTICLE_PATH_MARK = "/article/" # 文章链接特征
ARTICLE_DATE_RE = re.compile(r"/article/(\d{4})/(\d{1,2})/") # URL 日期格式
环境变量
| 变量 | 默认值 | 说明 |
|---|---|---|
LMSTUDIO_BASE_URL |
http://localhost:1234/v1 |
LM Studio OpenAI 兼容接口地址 |
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.