微型铸造原型
一个Python单仓库项目,探索模型上下文协议(MCP),并具备由Crawl4AI驱动的网页抓取功能。
概述
这个仓库的组织结构为 UV工作区 带有共享库和应用程序:
libs/跨应用程序共享的可重用库
- crawling基于Crawl4AI的网页抓取客户端
apps/应用项目
- uipac/ingestor内容摄入服务
特点/功能
- 🚀 表情符号“🚀”通常表示火箭、太空旅行或快速前进等概念,但直接翻译时,由于其本身是一种图形符号,没有直接的中文文字对应,所以可以意译为“火箭”或“飞速前进”等,具体根据上下文来确定。在没有具体上下文的情况下,一个通用的翻译是“火箭”。 快速依赖管理 (介词)和……一起;带着;具有 紫外线
- 🕷️(蜘蛛) 高级网页抓取 通过 Crawl4AI 可以翻译为“用于AI的爬虫”或“AI爬虫工具” 0.7.6
- 📦 表示“箱子”或“包裹”。 单仓库工作区 为了代码共享和一致性
- 🔧 修理工具/螺丝刀(或类似的修理相关图标含义) Makefile 对于可重复的开发工作流程
- 🎭 表情符号:小丑脸 剧作家集成 用于无头浏览器自动化
仓库结构
micro-casting-prototype/
├── pyproject.toml # Root workspace configuration
├── Makefile # Development automation
├── README.md # This file
├── .venv/ # Virtual environment (created on setup)
├── libs/ # Shared libraries
│ └── crawling/ # Web scraping library
│ ├── pyproject.toml # Crawl4AI dependency (0.7.6)
│ ├── README.md # Library documentation
│ └── src/
│ └── crawling/
│ ├── __init__.py
│ └── client.py # Main crawling implementation
└── apps/ # Application projects
└── uipac/
└── ingestor/ # Content ingestion app
└── pyproject.toml # Depends on "crawling"快速入门
先决条件
- Python 3.10及以上版本
- 紫外线 包管理器 (安装指南)
# Install uv (if not already installed)
curl -LsSf https://astral.sh/uv/install.sh | sh
# or on Windows:
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"设置
# Clone the repository
git clone
cd micro-casting-prototype
# Complete setup: sync dependencies, install packages, setup playwright
make setup
# Verify installation
make verify测试爬取库
# Test web scraping with example.com
make test-crawling
# Or run manually
uv run python -c "from crawling.client import fetch_markdown_sync; print(fetch_markdown_sync('https://example.com'))"可用命令
跑 make help 查看所有可用命令:
| 命令 | 描述 |
|---|---|
make setup | 完整设置:同步依赖项,安装包,配置 Playwright |
make sync 同步并解决工作区依赖项 | |
make install | 以可编辑模式安装工作区包 |
make playwright | 安装 Playwright 的 Chromium 浏览器 |
make test-crawling | 使用 example.com 测试爬虫库 |
make verify | 验证安装 |
make clean | 删除虚拟环境和缓存 |
make reinstall | 清理并重新安装所有内容 |
图书馆
爬行图书馆
位于 libs/crawling/这个库为网页抓取提供了一个简单的接口。
特点:
- 异步和同步API
- 内置缓存
- 无头浏览器自动化
- Markdown 输出
用法:
from crawling.client import fetch_markdown_sync
# Scrape a web page and get markdown
content = fetch_markdown_sync('https://example.com')
print(content)📖 书籍 完整文档
应用程序
UIPAC Ingestor(注:UIPAC可能是一个特定上下文或领域的缩写,这里直接保留原样,若UIPAC有特定含义,需根据上下文替换)翻译为中文可以是“UIPAC数据摄入器”或“UIPAC信息摄取器”,具体取决于“UIPAC”所代表的具体含义以及“Ingestor”在该上下文中的准确功能描述。如果“UIPAC”是一个已知的、有特定含义的术语,那么翻译时应替换为相应的中文表述。在缺乏具体上下文的情况下,“数据摄入器”或“信息摄取器”是一个较为通用的翻译
位于 apps/uipac/ingestor/这个应用程序负责内容摄入处理。
依赖项:
crawling库(用于网页抓取)
发展
添加新库
- 在(某个位置)创建一个新目录
libs/:
mkdir -p libs/mylib/src/mylib- 创建
libs/mylib/pyproject.toml:
[project]
name = "mylib"
version = "0.0.1"
requires-python = ">=3.10"
dependencies = []
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"- 以可编辑模式安装:
uv pip install -e libs/mylib添加新应用程序
- 在(某个位置)创建一个新目录
apps/:
mkdir -p apps/myapp- 创建
apps/myapp/pyproject.toml:
[project]
name = "myapp"
version = "0.0.1"
requires-python = ">=3.10"
dependencies = ["crawling"] # Add dependencies- 以可编辑模式安装:
uv pip install -e apps/myapp工作区配置
根源 pyproject.toml 定义工作区成员:
[tool.uv.workspace]
members = ["libs/*", "apps/*", "apps/*/*"]这允许:
- 共享依赖项一次钉定版本,随处可用
- 可编辑安装更改立即生效
- 跨项目导入从……导入
crawling,uipac等。
依赖管理
# Add a dependency to a specific package
cd libs/crawling
uv add requests
# Update all dependencies
uv sync --upgrade
# Lock dependencies without installing
uv lock关键技术
- 紫外线快速的Python包管理器(基于Rust)
- Crawl4AI 翻译为中文是“用于AI的爬虫”基于人工智能的网页抓取
- 剧作家浏览器自动化
- 幼崽(特指刚孵化出的动物)现代Python构建后端
工作空间优势
✅(对号,表示正确、确认或完成) 统一依赖管理一个锁定文件,版本一致 ✅ 代码重用跨应用共享库 ✅ 快速安装UV的并行下载和缓存 ✅ 可编辑模式变化瞬间传播 ✅ 简化的持续集成/持续部署(CI/CD)单身 make setup 命令
故障排除
未找到包
# Reinstall in editable mode
uv pip install -e libs/crawlingPlaywright 浏览器缺失
make playwright
# or
uv run playwright install chromium导入错误
# Verify workspace members
uv sync --verbose
# Check installed packages
uv pip list全新安装
make reinstall注释
uv sync读取工作区,并以可编辑模式安装库和应用程序crawl4ai被钉住一次后libs/crawling/pyproject.toml其他应用只是依赖于crawling- 保持每个子项目的
pyproject.toml最小的;最低限度的;uv自动处理链接
资源
许可证
\[您的许可证在此\]
做出贡献
\[如适用,请参阅贡献指南\]
