Scrapegraph-ai

活跃
GitHub Python MIT

简介

基于 AI 的 Python 爬虫框架,利用大语言模型和知识图谱自动构建网页数据提取管道。

核心特性

  • SmartScraperGraph — 单页提取管道,只需提示词和URL即可提取结构化数据
  • SearchGraph — 多页提取管道,从搜索引擎结果中批量提取信息
  • ScriptCreatorGraph — 根据网页内容自动生成Python爬虫脚本
  • 多模型支持 — 兼容OpenAI、Ollama、Groq、Azure、Gemini等多种LLM后端
  • MCP服务器集成 — 可作为MCP工具供AI Agent调用
  • 多格式支持 — 支持XML、HTML、JSON、Markdown等本地文档处理

适用场景

💡 从电商网站自动提取产品价格、评价和描述信息
💡 批量抓取搜索结果并结构化存储市场调研数据
💡 生成可复用的Python爬虫脚本,用于定期监控目标网站
💡 为AI Agent提供网页数据提取工具,支持RAG知识库构建
💡 处理本地HTML/JSON文件,提取关键信息用于数据分析

快速开始

pip install scrapegraphai
playwright install

from scrapegraphai.graphs import SmartScraperGraph

graph_config = {
    "llm": {"model": "ollama/llama3.2"},
    "verbose": True,
    "headless": False,
}

scraper = SmartScraperGraph(
    prompt="Extract product info from this page",
    source="https://example.com/product",
    config=graph_config
)
print(scraper.run())

相关项目