Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add examples for scrapegraph #5

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions Scrapegraph-ai/Scraper_docker.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"""
Basic example of scraping pipeline using SmartScraper
"""
from scrapegraphai.graphs import SmartScraperGraph

graph_config = {
"llm": {
"model": "ollama/mistral",
"temperature": 0,
"format": "json", # Ollama needs the format to be specified explicitly
# "model_tokens": 2000, # set context length arbitrarily,
},
}

smart_scraper_graph = SmartScraperGraph(
prompt="List me all the news with their description.",
source="https://perinim.github.io/projects",
config=graph_config
)

result = smart_scraper_graph.run()
print(result)
21 changes: 21 additions & 0 deletions Scrapegraph-ai/Scraper_gemini.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from scrapegraphai.graphs import SmartScraperGraph

OPENAI_API_KEY = "YOUR_API_KEY"

# Define the configuration for the graph
graph_config = {
"llm": {
"api_key": OPENAI_API_KEY,
"model": "gemini-pro",
},
}

# Create the SmartScraperGraph instance
smart_scraper_graph = SmartScraperGraph(
prompt="List me all the news with their description.",
file_source="https://www.wired.com/", # also accepts a string with the already downloaded HTML code in text format
config=graph_config
)

result = smart_scraper_graph.run()
print(result)
27 changes: 27 additions & 0 deletions Scrapegraph-ai/Scraper_ollama.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

from scrapegraphai.graphs import SmartScraperGraph

graph_config = {
"llm": {
"model": "ollama/mistral",
"temperature": 0,
"format": "json", # Ollama needs the format to be specified explicitly
# "model_tokens": 2000, # set context length arbitrarily,
"base_url": "http://localhost:11434", # set ollama URL arbitrarily
},
"embeddings": {
"model": "ollama/nomic-embed-text",
"temperature": 0,
"base_url": "http://localhost:11434", # set ollama URL arbitrarily
}
}


smart_scraper_graph = SmartScraperGraph(
prompt="List me all the news with their description.",
source="https://perinim.github.io/projects",
config=graph_config
)

result = smart_scraper_graph.run()
print(result)
21 changes: 21 additions & 0 deletions Scrapegraph-ai/Scraper_openai.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from scrapegraphai.graphs import SmartScraperGraph

OPENAI_API_KEY = "YOUR_API_KEY"

# Define the configuration for the graph
graph_config = {
"llm": {
"api_key": OPENAI_API_KEY,
"model": "gpt-3.5-turbo",
},
}

# Create the SmartScraperGraph instance
smart_scraper_graph = SmartScraperGraph(
prompt="List me all the news with their description.",
file_source="https://www.wired.com/", # also accepts a string with the already downloaded HTML code in text format
config=graph_config
)

result = smart_scraper_graph.run()
print(result)