# ๐ท๏ธ ScrapeGraphAI: ํ ๋ฐฉ์ ๋๋ด๋ ์น์คํฌ๋ํ
ScrapeGraphAI๋ ์น ์ฌ์ดํธ์ ๋ก์ปฌ ๋ฌธ์(XML, HTML, JSON ๋ฑ)์ ๋ํ ์คํฌ๋ํ ํ์ดํ๋ผ์ธ์ ๋ง๋ค๊ธฐ ์ํด LLM ๋ฐ ์ง์ ๊ทธ๋ํ ๋ก์ง์ ์ฌ์ฉํ๋ ํ์ด์ฌ ์น์คํฌ๋ํ ๋ผ์ด๋ธ๋ฌ๋ฆฌ์
๋๋ค.
์ถ์ถํ๋ ค๋ ์ ๋ณด๋ฅผ ๋งํ๊ธฐ๋ง ํ๋ฉด ๋ผ์ด๋ธ๋ฌ๋ฆฌ๊ฐ ์์์ ์ฒ๋ฆฌํด ์ค๋๋ค!
## ๐ ๋น ๋ฅธ ์ค์น
Scrapegraph-ai์ ๋ํ ์ฐธ์กฐ ํ์ด์ง๋ PyPI์ ๊ณต์ ํ์ด์ง์์ ํ์ธํ ์ ์์ต๋๋ค: [pypi](https://pypi.org/project/scrapegraphai/).
```bash
pip install scrapegraphai
```
์ฐธ๊ณ : ๋ค๋ฅธ ๋ผ์ด๋ธ๋ฌ๋ฆฌ์์ ์ถฉ๋์ ํผํ๊ธฐ ์ํด ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ๊ฐ์ ํ๊ฒฝ์ ์ค์นํ๋ ๊ฒ์ด ์ข์ต๋๋ค ๐ฑ
## ๐ ๋ฐ๋ชจ
๊ณต์ Streamlit ๋ฐ๋ชจ:
[](https://scrapegraph-ai-web-dashboard.streamlit.app)
Google Colab์ ์ฌ์ฉํ์ฌ ์น์์ ์ง์ ์ฌ์ฉํด ๋ณด์ธ์:
[](https://colab.research.google.com/drive/1sEZBonBMGP44CtO6GQTwAlL0BGJXjtfd?usp=sharing)
## ๐ ๋ฌธ์
ScrapeGraphAI์ ๋ํ ๋ฌธ์๋ [์ฌ๊ธฐ](https://scrapegraph-ai.readthedocs.io/en/latest/)์์ ์ฐพ์ ์ ์์ต๋๋ค.
๋ํ Docusaurus๋ฅผ [์ฌ๊ธฐ](https://scrapegraph-doc.onrender.com/)์์ ํ์ธํด ๋ณด์ธ์.
## ๐ป ์ฌ์ฉ๋ฒ
์น์ฌ์ดํธ(๋๋ ๋ก์ปฌ ํ์ผ)์์ ์ ๋ณด๋ฅผ ์ถ์ถํ๊ธฐ ์ํด ์ฌ์ฉํ ์ ์๋ ์ฌ๋ฌ ํ์ค ์คํฌ๋ํ ํ์ดํ๋ผ์ธ์ด ์์ต๋๋ค:
- `SmartScraperGraph`: ์ฌ์ฉ์ ํ๋กฌํํธ์ ์
๋ ฅ ์์ค๋ง ํ์๋ก ํ๋ ๋จ์ผ ํ์ด์ง ์คํฌ๋ํผ์
๋๋ค.
- `SearchGraph`: ๊ฒ์ ์์ง์ ์์ n๊ฐ ๊ฒ์ ๊ฒฐ๊ณผ์์ ์ ๋ณด๋ฅผ ์ถ์ถํ๋ ๋ค์ค ํ์ด์ง ์คํฌ๋ํผ์
๋๋ค.
- `SpeechGraph`: ์น์ฌ์ดํธ์์ ์ ๋ณด๋ฅผ ์ถ์ถํ๊ณ ์ค๋์ค ํ์ผ์ ์์ฑํ๋ ๋จ์ผ ํ์ด์ง ์คํฌ๋ํผ์
๋๋ค.
- `ScriptCreatorGraph`: ์น์ฌ์ดํธ์์ ์ ๋ณด๋ฅผ ์ถ์ถํ๊ณ Python ์คํฌ๋ฆฝํธ๋ฅผ ์์ฑํ๋ ๋จ์ผ ํ์ด์ง ์คํฌ๋ํผ์
๋๋ค.
- `SmartScraperMultiGraph`: ๋จ์ผ ํ๋กฌํํธ์ ์์ค ๋ชฉ๋ก์ ์ฌ์ฉํ์ฌ ์ฌ๋ฌ ํ์ด์ง์์ ์ ๋ณด๋ฅผ ์ถ์ถํ๋ ๋ค์ค ํ์ด์ง ์คํฌ๋ํผ์
๋๋ค.
- `ScriptCreatorMultiGraph`: ๋จ์ผ ํ๋กฌํํธ์ ์์ค ๋ชฉ๋ก์ ์ฌ์ฉํ์ฌ ์ฌ๋ฌ ํ์ด์ง์์ ์ ๋ณด๋ฅผ ์ถ์ถํ๋ Python ์คํฌ๋ฆฝํธ๋ฅผ ์์ฑํ๋ ๋ค์ค ํ์ด์ง ์คํฌ๋ํผ์
๋๋ค.
**OpenAI**, **Groq**, **Azure**, **Gemini**์ ๊ฐ์ API๋ฅผ ํตํด ๋ค์ํ LLM์ ์ฌ์ฉํ ์ ์์ผ๋ฉฐ, **Ollama**๋ฅผ ์ฌ์ฉํ์ฌ ๋ก์ปฌ ๋ชจ๋ธ๋ ์ฌ์ฉํ ์ ์์ต๋๋ค.
### ์ฌ๋ก 1: ๋ก์ปฌ ๋ชจ๋ธ์ ์ฌ์ฉํ๋ SmartScraper
[Ollama](https://ollama.com/)๋ฅผ ์ค์นํ๊ณ **ollama pull** ๋ช
๋ น์ ์ฌ์ฉํ์ฌ ๋ชจ๋ธ์ ๋ค์ด๋ก๋ํ์ธ์.
```python
from scrapegraphai.graphs import SmartScraperGraph
graph_config = {
"llm": {
"model": "ollama/mistral",
"temperature": 0,
"format": "json", # Ollama needs the format to be specified explicitly
"base_url": "http://localhost:11434", # set Ollama URL
},
"embeddings": {
"model": "ollama/nomic-embed-text",
"base_url": "http://localhost:11434", # set Ollama URL
},
"verbose": True,
}
smart_scraper_graph = SmartScraperGraph(
prompt="List me all the projects with their descriptions",
# also accepts a string with the already downloaded HTML code
source="https://perinim.github.io/projects",
config=graph_config
)
result = smart_scraper_graph.run()
print(result)
```
์ถ๋ ฅ์ ๋ค์๊ณผ ๊ฐ์ด ํ๋ก์ ํธ์ ์ค๋ช
์ ๋ชฉ๋ก์ด ๋ ๊ฒ์
๋๋ค:
```python
{'projects': [{'title': 'Rotary Pendulum RL', 'description': 'Open Source project aimed at controlling a real life rotary pendulum using RL algorithms'}, {'title': 'DQN Implementation from scratch', 'description': 'Developed a Deep Q-Network algorithm to train a simple and double pendulum'}, ...]}
```
### ์ฌ๋ก 2: ํผํฉ ๋ชจ๋ธ์ ์ฌ์ฉํ๋ SearchGraph
์ฐ๋ฆฌ๋ LLM์ **Groq**๋ฅผ ์ฌ์ฉํ๊ณ , ์๋ฒ ๋ฉ์ **Ollama**๋ฅผ ์ฌ์ฉํฉ๋๋ค.
```python
from scrapegraphai.graphs import SearchGraph
# Define the configuration for the graph
graph_config = {
"llm": {
"model": "groq/gemma-7b-it",
"api_key": "GROQ_API_KEY",
"temperature": 0
},
"embeddings": {
"model": "ollama/nomic-embed-text",
"base_url": "http://localhost:11434", # set ollama URL arbitrarily
},
"max_results": 5,
}
# Create the SearchGraph instance
search_graph = SearchGraph(
prompt="List me all the traditional recipes from Chioggia",
config=graph_config
)
# Run the graph
result = search_graph.run()
print(result)
```
์ถ๋ ฅ์ ๋ค์๊ณผ ๊ฐ์ด ๋ ์ํผ ๋ชฉ๋ก์ด ๋ ๊ฒ์
๋๋ค:
```python
{'recipes': [{'name': 'Sarde in Saรฒre'}, {'name': 'Bigoli in salsa'}, {'name': 'Seppie in umido'}, {'name': 'Moleche frite'}, {'name': 'Risotto alla pescatora'}, {'name': 'Broeto'}, {'name': 'Bibarasse in Cassopipa'}, {'name': 'Risi e bisi'}, {'name': 'Smegiassa Ciosota'}]}
```
### ์ฌ๋ก 3: OpenAI๋ฅผ ์ฌ์ฉํ๋ SpeechGraph
OpenAI API ํค์ ๋ชจ๋ธ ์ด๋ฆ๋ง ์ ๋ฌํ๋ฉด ๋ฉ๋๋ค.
```python
from scrapegraphai.graphs import SpeechGraph
graph_config = {
"llm": {
"api_key": "OPENAI_API_KEY",
"model": "openai/gpt-3.5-turbo",
},
"tts_model": {
"api_key": "OPENAI_API_KEY",
"model": "tts-1",
"voice": "alloy"
},
"output_path": "audio_summary.mp3",
}
# ************************************************
# Create the SpeechGraph instance and run it
# ************************************************
speech_graph = SpeechGraph(
prompt="Make a detailed audio summary of the projects.",
source="https://perinim.github.io/projects/",
config=graph_config,
)
result = speech_graph.run()
print(result)
```
์ถ๋ ฅ์ ํ์ด์ง์ ํ๋ก์ ํธ ์์ฝ์ด ํฌํจ๋ ์ค๋์ค ํ์ผ์ด ๋ ๊ฒ์
๋๋ค.
## ์คํฐ
## ๐ค ๊ธฐ์ฌ
๊ธฐ์ฌ๋ฅผ ํ์ํ๋ฉฐ, ๊ฐ์ ์ฌํญ์ ๋
ผ์ํ๊ณ ์ ์ ์ฌํญ์ ์ฃผ๊ณ ๋ฐ๊ธฐ ์ํด ์ฐ๋ฆฌ์ Discord ์๋ฒ์ ์ฐธ์ฌํ์ธ์!
๊ธฐ์ฌ ๊ฐ์ด๋๋ผ์ธ์ ์ฐธ๊ณ ํด์ฃผ์ธ์: [contributing guidelines](https://github.com/VinciGit00/Scrapegraph-ai/blob/main/CONTRIBUTING.md).
## ๐ ๋ก๋๋งต
๋ค์ ๊ธฐ๋ฅ๋ค์ ์์
ํ๊ณ ์์ต๋๋ค! ํ์
์ ๊ด์ฌ์ด ์์ผ์๋ฉด ํด๋น ๊ธฐ๋ฅ์ ๋ง์ฐ์ค ์ค๋ฅธ์ชฝ ๋ฒํผ์ผ๋ก ํด๋ฆญํ์ฌ ์ ํญ์์ PR์ ์์ฑํด์ฃผ์ธ์. ์๋ฌธ์ฌํญ์ด ์๊ฑฐ๋ ๋
ผ์ํ๊ณ ์ถ๋ค๋ฉด [Discord](https://discord.gg/uJN7TYcpNa)์์ ์ ํฌ์๊ฒ ์ฐ๋ฝํ๊ฑฐ๋ Github์ [Discussion](https://github.com/VinciGit00/Scrapegraph-ai/discussions) ํ์ด์ง๋ฅผ ์ด์ด์ฃผ์ธ์!
```mermaid
%%{init: {'theme': 'base', 'themeVariables': { 'primaryColor': '#5C4B9B', 'edgeLabelBackground':'#ffffff', 'tertiaryColor': '#ffffff', 'primaryBorderColor': '#5C4B9B', 'fontFamily': 'Arial', 'fontSize': '16px', 'textColor': '#5C4B9B' }}}%%
graph LR
A[DeepSearch Graph] --> F[Use Existing Chromium Instances]
F --> B[Page Caching]
B --> C[Screenshot Scraping]
C --> D[Handle Dynamic Content]
D --> E[New Webdrivers]
style A fill:#ffffff,stroke:#5C4B9B,stroke-width:2px,rx:10,ry:10
style F fill:#ffffff,stroke:#5C4B9B,stroke-width:2px,rx:10,ry:10
style B fill:#ffffff,stroke:#5C4B9B,stroke-width:2px,rx:10,ry:10
style C fill:#ffffff,stroke:#5C4B9B,stroke-width:2px,rx:10,ry:10
style D fill:#ffffff,stroke:#5C4B9B,stroke-width:2px,rx:10,ry:10
style E fill:#ffffff,stroke:#5C4B9B,stroke-width:2px,rx:10,ry:10
click A href "https://github.com/VinciGit00/Scrapegraph-ai/issues/260" "Open DeepSearch Graph Issue"
click F href "https://github.com/VinciGit00/Scrapegraph-ai/issues/329" "Open Chromium Instances Issue"
click B href "https://github.com/VinciGit00/Scrapegraph-ai/issues/197" "Open Page Caching Issue"
click C href "https://github.com/VinciGit00/Scrapegraph-ai/issues/197" "Open Screenshot Scraping Issue"
click D href "https://github.com/VinciGit00/Scrapegraph-ai/issues/279" "Open Handle Dynamic Content Issue"
click E href "https://github.com/VinciGit00/Scrapegraph-ai/issues/171" "Open New Webdrivers Issue"
```
## ๏ธ ๊ธฐ์ฌ์๋ค
[](https://github.com/VinciGit00/Scrapegraph-ai/graphs/contributors)
## ๐ ์ธ์ฉ
์ฐ๋ฆฌ์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ฐ๊ตฌ ๋ชฉ์ ์ผ๋ก ์ฌ์ฉํ ๊ฒฝ์ฐ ๋ค์๊ณผ ๊ฐ์ด ์ธ์ฉํด ์ฃผ์ธ์:
```text
@misc{scrapegraph-ai,
author = {Marco Perini, Lorenzo Padoan, Marco Vinciguerra},
title = {Scrapegraph-ai},
year = {2024},
url = {https://github.com/VinciGit00/Scrapegraph-ai},
note = {A Python library for scraping leveraging large language models}
}
```
## ์ ์๋ค
| | ์ฐ๋ฝ์ฒ |
|--------------------|---------------|
| Marco Vinciguerra | [](https://www.linkedin.com/in/marco-vinciguerra-7ba365242/) |
| Marco Perini | [](https://www.linkedin.com/in/perinim/) |
| Lorenzo Padoan | [](https://www.linkedin.com/in/lorenzo-padoan-4521a2154/) |
## ๐ ๋ผ์ด์ ์ค
ScrapeGraphAI๋ MIT License๋ก ๋ฐฐํฌ๋์์ต๋. ์์ธํ ๋ด์ฉ์ [LICENSE](https://github.com/VinciGit00/Scrapegraph-ai/blob/main/LICENSE) ํ์ผ์ ์ฐธ์กฐํ์ธ์.
## ๊ฐ์ฌ์ ๋ง
- ํ๋ก์ ํธ์ ๊ธฐ์ฌํ ๋ชจ๋ ๋ถ๋ค๊ณผ ์คํ ์์ค ์ปค๋ฎค๋ํฐ์ ๊ฐ์ฌ๋๋ฆฝ๋๋ค.
- ScrapeGraphAI๋ ๋ฐ์ดํฐ ํ์ ๋ฐ ์ฐ๊ตฌ ๋ชฉ์ ์ผ๋ก๋ง ์ฌ์ฉ๋์ด์ผ ํฉ๋๋ค. ์ฐ๋ฆฌ๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ์ ์ค์ฉ์ ๋ํด ์ฑ
์์ ์ง์ง ์์ต๋๋ค.