自适应 Web 爬虫框架,基于 D4Vinci/Scrapling,提供网页抓取、内容提取、智能数据采集、截图和数据导出功能。
- 🚀 超快速度 - 比 BeautifulSoup 快 1000 倍
- 🧠 自适应 - 解析器能"学习"网站结构变化,自动重新适配
- 🎭 多种模式 - 静态请求、隐身模式、动态渲染(Playwright)
- 🔄 自动重试 - 内置错误处理和重试机制
- 📝 编码处理 - 自动处理各种编码问题
pip install scrapling>=1.0.0 playwright>=1.40.0 pandas>=2.0.0
playwright install chromium
from fetch import scrapling_fetch
from extract import scrapling_extract
from auto import scrapling_auto
# 网页抓取
html = scrapling_fetch("https://example.com")
# 使用选择器提取
title = scrapling_fetch("https://example.com", selector="h1")
# 智能抓取
data = scrapling_auto("https://news.ycombinator.com/")
| 模块 |
功能 |
fetch |
网页抓取(static/stealth/dynamic 模式) |
extract |
CSS/XPath 内容提取 |
auto |
自动检测页面数据结构 |
screenshot |
网页截图 |
export |
JSON/CSV 格式转换 |
| 模式 |
说明 |
适用场景 |
static |
静态 HTML 请求 |
简单页面 |
stealth |
隐身模式,反反爬 |
需要规避检测的网站 |
dynamic |
JavaScript 渲染 |
React/Vue/Angular 等 SPA |
python test_scrapling.py
python test_hackernews.py
python test_scrapling_local.py
scrapling/
├── tools/
│ ├── fetch.py # 网页抓取
│ ├── extract.py # 内容提取
│ ├── auto.py # 智能抓取
│ ├── screenshot.py # 截图
│ └── export.py # 格式转换
├── pyproject.toml
├── SKILL.md
└── test_*.py