Files
wehub-resource-sync 9db2d0b663
CodeQL / Analyze (python) (push) Has been cancelled
Release / Build (push) Has been cancelled
Test Suite / Unit Tests (push) Has been cancelled
Release / Release (push) Has been cancelled
docs: make Chinese README the default
2026-07-13 10:53:39 +00:00

262 lines
13 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!-- WEHUB_ZH_README -->
> [!NOTE]
> 本文档由 WeHub 基于上游 README 翻译整理,属于社区翻译,非官方中文文档。
> [English](./README.en.md) · [原始项目](https://github.com/ScrapeGraphAI/Scrapegraph-ai) · [上游 README](https://github.com/ScrapeGraphAI/Scrapegraph-ai/blob/HEAD/README.md)
> 原作者、版权与许可证归属以原始项目及本仓库 LICENSE 文件为准。
## 🚀 **想要一种更快、更简单的规模化爬取方式(仅需 5 行代码)?** 请访问我们的增强版:[**ScrapeGraphAI.com**](https://scrapegraphai.com/?utm_source=github&utm_medium=readme&utm_campaign=oss_cta&ut#m_content=top_banner)! 🚀
---
# 🕷️ ScrapeGraphAI:只需爬取一次
<p align="center">
<a href="https://scrapegraphai.com">
<img src="media/banner.png" alt="ScrapeGraphAI" style="width: 100%;">
</a>
</p>
[English](README.md) | [中文](docs/chinese.md) | [日本語](docs/japanese.md)
| [한국어](docs/korean.md)
| [Русский](docs/russian.md) | [Türkçe](docs/turkish.md)
| [Deutsch](docs/german.md)
| [Español](docs/spanish.md)
| [français](docs/french.md)
| [Português](docs/portuguese.md)
| [Italiano](docs/italian.md)
[![PyPI Downloads](https://static.pepy.tech/personalized-badge/scrapegraphai?period=total&units=INTERNATIONAL_SYSTEM&left_color=BLACK&right_color=GREEN&left_text=downloads)](https://pepy.tech/projects/scrapegraphai)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=for-the-badge)](https://opensource.org/licenses/MIT)
[![](https://dcbadge.vercel.app/api/server/gkxQDAjfeX)](https://discord.gg/gkxQDAjfeX)
<p align="center">
<a href="https://trendshift.io/repositories/15078" target="_blank"><img src="https://trendshift.io/api/badge/repositories/15078" alt="ScrapeGraphAI%2FScrapegraph-ai | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a>
<p align="center">
[ScrapeGraphAI](https://scrapegraphai.com) is a *web scraping* python library that uses LLM and direct graph logic to create scraping pipelines for websites and local documents (XML, HTML, JSON, Markdown, etc.).
只需说明你想提取哪些信息,库会替你完成!
## 🚀 集成
ScrapeGraphAI 可与主流框架和工具无缝集成,增强你的爬取能力。无论你使用 Python 或 Node.js 开发、使用 LLM 框架,还是与无代码平台协作,我们都提供全面的集成选项..
<p align="center">
<a href="https://scrapegraphai.com">
<img src="https://raw.githubusercontent.com/ScrapeGraphAI/.github/main/profile/assets/api_banner.png" alt="Web data extraction at scale? Try ScrapeGraphAI cloud" style="width: 100%;">
</a>
</p>
更多信息请参阅以下[链接](https://scrapegraphai.com)
**集成**
- **API**: [Documentation](https://docs.scrapegraphai.com/introduction)
- **SDKs**: [Python](https://docs.scrapegraphai.com/sdks/python), [Node](https://docs.scrapegraphai.com/sdks/javascript)
- **LLM Frameworks**: [Langchain](https://docs.scrapegraphai.com/integrations/langchain), [Llama Index](https://docs.scrapegraphai.com/integrations/llamaindex), [Crew.ai](https://docs.scrapegraphai.com/integrations/crewai), [Agno](https://docs.scrapegraphai.com/integrations/agno), [CamelAI](https://github.com/camel-ai/camel)
- **Low-code Frameworks**: [Pipedream](https://pipedream.com/apps/scrapegraphai), [Bubble](https://bubble.io/plugin/scrapegraphai-1745408893195x213542371433906180), [Zapier](https://zapier.com/apps/scrapegraphai/integrations), [n8n](http://localhost:5001/dashboard), [Dify](https://dify.ai), [Toolhouse](https://app.toolhouse.ai/mcp-servers/scrapegraph_smartscraper)
- **MCP server**: [Link](https://smithery.ai/server/@ScrapeGraphAI/scrapegraph-mcp)
## 🚀 快速安装
Scrapegraph-ai 的参考页面可在 PyPI 官方页面查看:[pypi](https://pypi.org/project/scrapegraphai/).
```bash
pip install scrapegraphai
# IMPORTANT (for fetching websites content)
playwright install
```
**注意**:建议在虚拟环境中安装本库,以避免与其他库发生冲突 🐱
## 💻 用法
有多种标准爬取流水线可用于从网站(或本地文件)提取信息。
最常用的是 `SmartScraperGraph`,它根据用户提示和源 URL 从单个页面提取信息。
```python
from scrapegraphai.graphs import SmartScraperGraph
# Define the configuration for the scraping pipeline
graph_config = {
"llm": {
"model": "ollama/llama3.2",
"model_tokens": 8192,
"format": "json",
},
"verbose": True,
"headless": False,
}
# Create the SmartScraperGraph instance
smart_scraper_graph = SmartScraperGraph(
prompt="Extract useful information from the webpage, including a description of what the company does, founders and social media links",
source="https://scrapegraphai.com/",
config=graph_config
)
# Run the pipeline
result = smart_scraper_graph.run()
import json
print(json.dumps(result, indent=4))
```
> [!NOTE]
> 对于 OpenAI 及其他模型,你只需修改 llm 配置!
> ```python
>graph_config = {
> "llm": {
> "api_key": "YOUR_OPENAI_API_KEY",
> "model": "openai/gpt-4o-mini",
> },
> "verbose": True,
> "headless": False,
>}
>```
输出将如下所示的字典:
```python
{
"description": "ScrapeGraphAI transforms websites into clean, organized data for AI agents and data analytics. It offers an AI-powered API for effortless and cost-effective data extraction.",
"founders": [
{
"name": "",
"role": "Founder & Technical Lead",
"linkedin": "https://www.linkedin.com/in/perinim/"
},
{
"name": "Marco Vinciguerra",
"role": "Founder & Software Engineer",
"linkedin": "https://www.linkedin.com/in/marco-vinciguerra-7ba365242/"
},
{
"name": "Lorenzo Padoan",
"role": "Founder & Product Engineer",
"linkedin": "https://www.linkedin.com/in/lorenzo-padoan-4521a2154/"
}
],
"social_media_links": {
"linkedin": "https://www.linkedin.com/company/101881123",
"twitter": "https://x.com/scrapegraphai",
"github": "https://github.com/ScrapeGraphAI/Scrapegraph-ai"
}
}
```
还有其他流水线可用于从多个页面提取信息、生成 Python 脚本,甚至生成音频文件。
| 流水线名称 | 说明 |
|-------------------------|------------------------------------------------------------------------------------------------------------------|
| SmartScraperGraph | 单页爬取器,仅需用户提示和输入源。 |
| SearchGraph | 多页爬取器,从搜索引擎前 n 条搜索结果中提取信息。 |
| SpeechGraph | 单页爬取器,从网站提取信息并生成音频文件。 |
| ScriptCreatorGraph | 单页爬取器,从网站提取信息并生成 Python 脚本。 |
| SmartScraperMultiGraph | 多页爬取器,根据单一提示和源列表从多个页面提取信息。 |
| ScriptCreatorMultiGraph | 多页爬取器,生成用于从多个页面和源提取信息的 Python 脚本。 |
这些图(graph)各自都有 multi 版本,可并行调用 LLM。
可通过 API 使用不同的 LLM,例如 **OpenAI**、**Groq**、**Azure**、**Gemini**、**MiniMax** 等,也可通过 **Ollama** 使用本地模型。
若要使用本地模型,请确保已安装 [Ollama](https://ollama.com/),并使用 **ollama pull** 命令下载模型。
## 📖 文档
[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1sEZBonBMGP44CtO6GQTwAlL0BGJXjtfd?usp=sharing)
ScrapeGraphAI 文档见[此处](https://docs.scrapegraphai.com/introduction).
## 🆚 开源版 vs 托管 API
ScrapeGraphAI 提供两种形态:**本开源库**由你自行部署运行,以及通过 [Python](https://github.com/ScrapeGraphAI/scrapegraph-py) 和 [JS/TS](https://github.com/ScrapeGraphAI/scrapegraph-js) SDK 调用的**托管云 API**。下表说明两者的差异,便于你选择合适方案。
| | 开源版 (`scrapegraphai`) | 托管 API (`scrapegraph-py` / `scrapegraph-js`) |
|---|---|---|
| **它是什么** | 由你自行运行的 Python 库 | 通过 SDK 调用的托管云服务 |
| **运行位置** | 你自己的基础设施(自托管) | ScrapeGraphAI 云端 |
| **LLM** | 自带(OpenAI、Groq、Gemini、Azure,或通过 Ollama 本地运行) | 由平台托管 |
| **浏览器 / JS 渲染** | 自行配置(Playwright | 托管(隐身模式,`auto`/`fast`/`js` 模式) |
| **代理与反爬** | 自行负责 | 已包含 |
| **扩展与维护** | 自行负责 | 全托管 |
| **成本模式** | LLM token + 自有基础设施 | 按用量付费积分 |
| **认证** | 使用你自己的 LLM 密钥 | `SGAI_API_KEY` |
| **能力** | 图流水线(SmartScraper、Search、Speech、ScriptCreator…) | Scrape、Extract、Search、Crawl、Monitor、History |
| **搭建工作量** | 配置较多 | 最少——API 密钥 + 一次调用 |
| **许可证** | MIT | SDK 为 MITAPI 服务为付费 |
**选择开源库**,若你需要完全控制、本地/自托管数据、本地 LLM(Ollama)或精细成本调优——并愿意自行管理浏览器、代理与扩展。
**选择托管 API**,若你需要零基础设施、托管 JS 渲染与反爬、内置 **Crawl** 与定时 **Monitor** 任务,以及最快上线路径——按积分计费。
- 开源库:https://github.com/ScrapeGraphAI/Scrapegraph-ai
- Python SDKhttps://github.com/ScrapeGraphAI/scrapegraph-py
- JS/TS SDKhttps://github.com/ScrapeGraphAI/scrapegraph-js
- API 文档:https://docs.scrapegraphai.com/introduction
## 🤝 参与贡献
欢迎贡献并加入我们的 Discord 服务器,与我们讨论改进并向我们提出建议!
请参阅[贡献指南](https://github.com/ScrapeGraphAI/Scrapegraph-ai/blob/main/CONTRIBUTING.md).
[![My Skills](https://skillicons.dev/icons?i=discord)](https://discord.gg/uJN7TYcpNa)
[![My Skills](https://skillicons.dev/icons?i=linkedin)](https://www.linkedin.com/company/scrapegraphai/)
[![My Skills](https://skillicons.dev/icons?i=twitter)](https://twitter.com/scrapegraphai)
## 🔗 ScrapeGraph API 与 SDK
若你正在寻找将 ScrapeGraph 集成到系统中的快捷方案,请查看我们强大的 API [这里!](https://scrapegraphai.com)
[![API Banner](https://raw.githubusercontent.com/ScrapeGraphAI/Scrapegraph-ai/main/docs/assets/api_banner.png)](https://scrapegraphai.com)
我们提供 Python 和 Node.js 两套 SDK,便于集成到你的项目中。请在下方查看:
| SDK | 语言 | GitHub 链接 |
|-----------|----------|-----------------------------------------------------------------------------|
| Python SDK | Python | [scrapegraph-py](https://docs.scrapegraphai.com/sdks/python) |
| Node.js SDK | Node.js | [scrapegraph-js](https://docs.scrapegraphai.com/sdks/javascript) |
官方 API 文档可在此查看 [这里](https://docs.scrapegraphai.com/introduction).
## 📈 遥测(Telemetry
我们收集匿名使用指标以提升软件包质量与用户体验。这些数据帮助我们优先改进并确保兼容性。若要退出,请设置环境变量 SCRAPEGRAPHAI_TELEMETRY_ENABLED=false。更多信息请参阅文档 [这里](https://docs.scrapegraphai.com/introduction).
## ❤️ 贡献者
[![Contributors](https://contrib.rocks/image?repo=ScrapeGraphAI/Scrapegraph-ai)](https://github.com/ScrapeGraphAI/Scrapegraph-ai/graphs/contributors)
## 🎓 引用
若你在研究中使用了本库,请使用以下文献引用我们:
```text
@misc{scrapegraph-ai,
author = {Lorenzo Padoan, Marco Vinciguerra},
title = {Scrapegraph-ai},
year = {2024},
url = {https://github.com/ScrapeGraphAI/Scrapegraph-ai},
note = {A Python library for scraping leveraging large language models}
}
```
## 作者
| | 联系方式 |
|--------------------|----------------------|
| Marco Vinciguerra | [![Linkedin Badge](https://img.shields.io/badge/-Linkedin-blue?style=flat&logo=Linkedin&logoColor=white)](https://www.linkedin.com/in/marco-vinciguerra-7ba365242/) |
| Lorenzo Padoan | [![Linkedin Badge](https://img.shields.io/badge/-Linkedin-blue?style=flat&logo=Linkedin&logoColor=white)](https://www.linkedin.com/in/lorenzo-padoan-4521a2154/) |
## 📜 许可证
ScrapeGraphAI 采用 MIT 许可证。更多信息请参阅 [LICENSE](https://github.com/ScrapeGraphAI/Scrapegraph-ai/blob/main/LICENSE) 文件。
## 致谢
- 感谢所有项目贡献者及开源社区的支持。
- ScrapeGraphAI 仅用于数据探索与研究目的。我们不对库的滥用承担责任。
由 [ScrapeGraph AI](https://scrapegraphai.com) 用 ❤️ 打造
[Scarf tracking](https://static.scarf.sh/a.png?x-pxid=102d4b8c-cd6a-4b9e-9a16-d6d141b9212d)