项目简介
Scrapling 是一个自适应网页抓取框架,支持从单次请求到大规模爬取。其解析器能学习网站变化,在页面更新时自动重定位元素。它内置绕过 Cloudflare Turnstile 等反爬系统,并支持并发多会话爬取和代理轮换。
README 预览
\n\n\n \n \n \n \n \n \n \n Effortless Web Scraping for the Modern Web\n\n\n\n \n \n العربيه | Español | Português (Brasil) | Français | Deutsch | 简体中文 | 日本語 | Русский | 한국어\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n\n\n Selection methods\n ·\n Fetchers\n ·\n Spiders\n ·\n Proxy Rotation\n ·\n CLI\n ·\n MCP\n\n\nScrapling is an adaptive Web Scraping framework that handles everything from a single request to a full-scale crawl.\n\nIts parser learns from website changes and automatically relocates your elements when pages update. Its fetchers bypass anti-bot systems like Cloudflare Turnstile out of the box. And its spider framework lets you scale up to concurrent, multi-session crawls with pause/resume and automatic proxy rotation - all in a few lines of Python. One library, zero compromises.\n\nBlazing fast crawls with real-time stats and streaming. Built by Web Scrapers for Web Scrapers and regular users, there's something for everyone.\n\n```python\nfrom scrapling.fetchers import Fetcher, AsyncFetcher, StealthyFetcher, DynamicFetcher\nStealthyFetcher.adaptive = True\np = StealthyFetcher.fetch('https://example.com', headless=True, network_idle=True) # Fetch website under the radar!\nproducts = p.css('.product', auto_save=True) # Scrape data that survives website design changes!\nproducts = p.css('.product', adaptive=True) # Later, if the website structure changes, pass `adaptive=True` to find them!\n```\nOr scale up to full crawls\n```python\nfrom scrapling.spiders import Spider, Response\n\nclass MySpider(Spider):\n name = "demo"\n start_urls = ["https://example.com/"]\n\n async def parse(self, response: Response):\n for item in response.css('.product'):\n常见问题 (5)
故障排除如何修复 Claude Desktop 中的 Docker MCP 连接错误:'pull access denied for scrapling, repository does not exist'?
在 claude_desktop_config.json 中使用完整的 Docker 镜像名称 pyd4vinci/scrapling,而不是 scrapling。
1. 拉取镜像:
docker pull pyd4vinci/scrapling
2. 更新 MCP 服务器配置:
{
"mcpServers": {
"ScraplingServer": {
"command": "/usr/local/bin/docker",
"args": ["run", "-i", "--rm", "pyd4vinci/scrapling", "mcp"]
}
}
}
在 macOS 上,command 也可以是 "docker" 或 /usr/local/bin/docker,具体取决于你的 Docker 安装方式。
3. 保存文件并完全重启 Claude Desktop。
出现该错误是因为 Docker 会将 scrapling 解释为名为 scrapling:latest 的镜像,而实际拉取的镜像是 pyd4vinci/scrapling:latest。
故障排除如何修复 scrapling 在 lxml 6 中出现的 "DeprecationWarning: The 'strip_cdata' option of HTMLParser()" 警告?
此警告出现的原因是:scrapling(≤0.4.15)向 lxml 的 HTMLParser() 传入了 strip_cdata 参数,而 lxml 6 已弃用该参数(该选项从未产生过任何效果,之后将被移除,届时会抛出 TypeError)。修复方法:
1. **升级 scrapling** —— 维护者已在 dev 分支中移除了该选项,因此请升级到 0.4.15 之后的版本:pip install -U scrapling
2. **临时解决办法 —— 将 lxml 固定在 6 以下**:pip install "lxml<6"
3. **屏蔽该警告**(如果必须保持当前版本):在创建 Selector 之前添加 warnings.filterwarnings("ignore", message=".*strip_cdata.*", category=DeprecationWarning)。
故障排除为什么当 solve_cloudflare=True 时,Scrapling StealthyFetcher 的 fetch() 耗时远超 timeout?
在 Scrapling 0.4.15 中,Cloudflare Turnstile 求解器会等待一个永远无法匹配某些挑战变体的 widget 定位器,且其重试循环没有上限——因此一次 fetch(..., timeout=15000) 调用可能运行 74 秒以上(timeout 参数是单次操作的限制,而非整个 fetch 的总时限)。修复方法与变通方案:
1. **升级**:已在 dev 分支上修复,将随下一个版本发布——移除了对缺失 widget 的等待,并为求解器的重试循环设置了上限。安装 dev 构建版本,或在新版本发布后升级到高于 0.4.15 的版本。
2. **复用会话**:cf_clearance cookie 会持续有效,因此只有第一次 fetch 会触发求解器。实测:首页约 8 秒,之后每页约 3 秒。
3. **外部计时**:在独立的 worker 进程中运行 fetch,并终止任何超过你设定时限的进程,因为在受影响的版本中,仅靠 timeout= 无法限制调用总时长。
请注意,调用仍会以状态码 200 成功返回正确的内容——这纯粹是一个延迟问题,而非调用失败。
故障排除如何修复在 Windows 上以管理员身份运行时出现的 StealthyFetcher TargetClosedError?
当 Python 在 Windows 上以提升权限(管理员)运行时,Scrapling 额外的 --disable-features 开关会替换 patchright/Playwright 的列表,从而丢弃 AutoDeElevate。Chromium 随后以降权状态重新启动并退出,导致 TargetClosedError: BrowserType.launch_persistent_context。针对 scrapling 0.4.15 的临时解决方法:显式传递反降权标志:
from scrapling.fetchers import StealthyFetcher
StealthyFetcher.fetch("https://example.com", headless=True, extra_flags=["--do-not-de-elevate"])
永久修复:disabled-features 列表已在 dev 分支中合并,因此请升级到 0.4.15 之后的下一个版本。或者,在非提升权限的 shell 中运行该脚本。
故障排除为什么ClawHub上Scrapling技能页面为空白或无法显示?
这是一次临时中断(openclaw/clawhub#2345),现已解决。页面 https://clawhub.ai/D4Vinci/scrapling-official 目前正常运行。如果您仍然看到空白页面,请尝试使用 agent-skill GitHub 目录中的 zip 文件作为备用方案:https://github.com/D4Vinci/Scrapling/tree/main/agent-skill。