來源
工具用途
- 把網頁內容抓取後轉成「乾淨、LLM 友好」的 Markdown,適合:
- RAG 資料整理 - Agent 任務(例如:搜集資料 -> 摘要 -> 結構化輸出) - 資料管線(內容抽取/清洗)
安裝 / 取得(Python)
pip install -U crawl4ai # 安裝後設定與診斷 crawl4ai-setup crawl4ai-doctor (以官方 README 的 Quick Start 為準)
python -m playwright install --with-deps chromium 如遇到瀏覽器依賴,可用 Playwright 安裝:
常用操作 / 指令
Python(最小示例)
import asyncio from crawl4ai import AsyncWebCrawler async def main(): async with AsyncWebCrawler() as crawler: result = await crawler.arun(url="https://example.com") print(result.markdown) asyncio.run(main()) CLI(快速抓取)
# 輸出 markdown crwl https://example.com -o markdown # 深度抓取(例如:BFS、限制頁數) crwl https://docs.crawl4ai.com --deep-crawl bfs --max-pages 10 適用情境
- 你需要快速把網站內容整理成可搜尋、可餵給 LLM 的格式
- 你要抓 docs/知識庫/文章,做成自己的「素材索引」再沉澱 實用教學
不適用 / 風險(務必注意)
- 法規/合規:請遵守網站 ToS、robots.txt、著作權與個資法規
- 反爬/驗證:有些站點會出現驗證頁/封鎖(可能需要更進階設定或改用資料來源)
- 成本:大規模抓取會吃 CPU/網路/時間(先小量驗證再擴大)
延伸
- B站筆記:06_賺錢方法_副業方法/B站/2026/01/crawl4ai_数行代码搞定数据采集
Tags
- #crawler
- #crawl4ai
- #python
- #rag
- #agent
留言
暫時未有公開留言。
登入後可以留言。