Skip to content

Commit

Permalink
add smartscraper lite
Browse files Browse the repository at this point in the history
  • Loading branch information
VinciGit00 committed Oct 21, 2024
1 parent 2991ca8 commit b84883b
Show file tree
Hide file tree
Showing 18 changed files with 544 additions and 0 deletions.
32 changes: 32 additions & 0 deletions examples/anthropic/smart_scraper_lite_anthropic.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"""
Basic example of scraping pipeline using SmartScraper
"""
import os
import json
from dotenv import load_dotenv
from scrapegraphai.graphs import SmartScraperLiteGraph
from scrapegraphai.utils import prettify_exec_info

load_dotenv()

graph_config = {
"llm": {
"api_key": os.getenv("ANTHROPIC_API_KEY"),
"model": "anthropic/claude-3-haiku-20240307",
},
"verbose": True,
"headless": False,
}

smart_scraper_lite_graph = SmartScraperLiteGraph(
prompt="Who is Marco Perini?",
source="https://perinim.github.io/",
config=graph_config
)

result = smart_scraper_lite_graph.run()
print(json.dumps(result, indent=4))

graph_exec_info = smart_scraper_lite_graph.get_execution_info()
print(prettify_exec_info(graph_exec_info))

31 changes: 31 additions & 0 deletions examples/azure/smart_scraper_lite_azure.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"""
Basic example of scraping pipeline using SmartScraper
"""
import os
import json
from dotenv import load_dotenv
from scrapegraphai.graphs import SmartScraperLiteGraph
from scrapegraphai.utils import prettify_exec_info

load_dotenv()

graph_config = {
"llm": {
"api_key": os.environ["AZURE_OPENAI_KEY"],
"model": "azure_openai/gpt-4o"
},
"verbose": True,
"headless": False
}

smart_scraper_lite_graph = SmartScraperLiteGraph(
prompt="Who is Marco Perini?",
source="https://perinim.github.io/",
config=graph_config
)

result = smart_scraper_lite_graph.run()
print(json.dumps(result, indent=4))

graph_exec_info = smart_scraper_lite_graph.get_execution_info()
print(prettify_exec_info(graph_exec_info))
26 changes: 26 additions & 0 deletions examples/bedrock/smart_scraper_lite_bedrock.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"""
Basic example of scraping pipeline using SmartScraper
"""
import json
from scrapegraphai.graphs import SmartScraperLiteGraph
from scrapegraphai.utils import prettify_exec_info

graph_config = {
"llm": {
"client": "client_name",
"model": "bedrock/anthropic.claude-3-sonnet-20240229-v1:0",
"temperature": 0.0
}
}

smart_scraper_lite_graph = SmartScraperLiteGraph(
prompt="Who is Marco Perini?",
source="https://perinim.github.io/",
config=graph_config
)

result = smart_scraper_lite_graph.run()
print(json.dumps(result, indent=4))

graph_exec_info = smart_scraper_lite_graph.get_execution_info()
print(prettify_exec_info(graph_exec_info))
31 changes: 31 additions & 0 deletions examples/deepseek/smart_scraper_lite_deepseek.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"""
Basic example of scraping pipeline using SmartScraper
"""
import os
import json
from dotenv import load_dotenv
from scrapegraphai.graphs import SmartScraperLiteGraph
from scrapegraphai.utils import prettify_exec_info

load_dotenv()

graph_config = {
"llm": {
"api_key": os.getenv("DEEPSEEK_API_KEY"),
"model": "deepseek/deepseek-coder-33b-instruct",
},
"verbose": True,
"headless": False,
}

smart_scraper_lite_graph = SmartScraperLiteGraph(
prompt="Who is Marco Perini?",
source="https://perinim.github.io/",
config=graph_config
)

result = smart_scraper_lite_graph.run()
print(json.dumps(result, indent=4))

graph_exec_info = smart_scraper_lite_graph.get_execution_info()
print(prettify_exec_info(graph_exec_info))
31 changes: 31 additions & 0 deletions examples/ernie/smart_scraper_lite_ernie.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"""
Basic example of scraping pipeline using SmartScraper
"""
import os
import json
from dotenv import load_dotenv
from scrapegraphai.graphs import SmartScraperLiteGraph
from scrapegraphai.utils import prettify_exec_info

load_dotenv()

graph_config = {
"llm": {
"api_key": os.getenv("ERNIE_API_KEY"),
"model": "ernie/ernie-bot-4",
},
"verbose": True,
"headless": False,
}

smart_scraper_lite_graph = SmartScraperLiteGraph(
prompt="Who is Marco Perini?",
source="https://perinim.github.io/",
config=graph_config
)

result = smart_scraper_lite_graph.run()
print(json.dumps(result, indent=4))

graph_exec_info = smart_scraper_lite_graph.get_execution_info()
print(prettify_exec_info(graph_exec_info))
31 changes: 31 additions & 0 deletions examples/fireworks/smart_scraper_lite_fireworks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"""
Basic example of scraping pipeline using SmartScraper
"""
import os
import json
from dotenv import load_dotenv
from scrapegraphai.graphs import SmartScraperLiteGraph
from scrapegraphai.utils import prettify_exec_info

load_dotenv()

graph_config = {
"llm": {
"api_key": os.getenv("FIREWORKS_API_KEY"),
"model": "fireworks/llama-v2-70b-chat",
},
"verbose": True,
"headless": False,
}

smart_scraper_lite_graph = SmartScraperLiteGraph(
prompt="Who is Marco Perini?",
source="https://perinim.github.io/",
config=graph_config
)

result = smart_scraper_lite_graph.run()
print(json.dumps(result, indent=4))

graph_exec_info = smart_scraper_lite_graph.get_execution_info()
print(prettify_exec_info(graph_exec_info))
31 changes: 31 additions & 0 deletions examples/google_genai/smart_scraper_lite_google_genai.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"""
Basic example of scraping pipeline using SmartScraper
"""
import os
import json
from dotenv import load_dotenv
from scrapegraphai.graphs import SmartScraperLiteGraph
from scrapegraphai.utils import prettify_exec_info

load_dotenv()

graph_config = {
"llm": {
"api_key": os.getenv("GOOGLE_API_KEY"),
"model": "gemini-pro",
},
"verbose": True,
"headless": False,
}

smart_scraper_lite_graph = SmartScraperLiteGraph(
prompt="Who is Marco Perini?",
source="https://perinim.github.io/",
config=graph_config
)

result = smart_scraper_lite_graph.run()
print(json.dumps(result, indent=4))

graph_exec_info = smart_scraper_lite_graph.get_execution_info()
print(prettify_exec_info(graph_exec_info))
33 changes: 33 additions & 0 deletions examples/google_vertexai/smart_scraper_lite_google_vertexai.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
"""
Basic example of scraping pipeline using SmartScraper
"""
import os
import json
from dotenv import load_dotenv
from scrapegraphai.graphs import SmartScraperLiteGraph
from scrapegraphai.utils import prettify_exec_info

load_dotenv()

graph_config = {
"llm": {
"project": os.getenv("GOOGLE_CLOUD_PROJECT"),
"location": "us-central1",
"model": "text-bison@001",
},
"verbose": True,
"headless": False,
}

smart_scraper_lite_graph = SmartScraperLiteGraph(
prompt="Who is Marco Perini?",
source="https://perinim.github.io/",
config=graph_config
)

result = smart_scraper_lite_graph.run()
print(json.dumps(result, indent=4))

graph_exec_info = smart_scraper_lite_graph.get_execution_info()
print(prettify_exec_info(graph_exec_info))

47 changes: 47 additions & 0 deletions examples/google_vertexai/smart_scraper_multi_lite_vertex.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
"""
Basic example of scraping pipeline using SmartScraper
"""
import os
import json
from dotenv import load_dotenv
from scrapegraphai.graphs import SmartScraperMultiLiteGraph
from scrapegraphai.utils import prettify_exec_info

load_dotenv()

# ************************************************
# Define the configuration for the graph
# ************************************************

graph_config = {
"llm": {
"project": os.getenv("GOOGLE_CLOUD_PROJECT"),
"location": "us-central1",
"model": "text-bison@001",
},
"verbose": True,
"headless": False,
}

# ************************************************
# Create the SmartScraperGraph instance and run it
# ************************************************

smart_scraper_multi_lite_graph = SmartScraperMultiLiteGraph(
prompt="Who is Marco Perini?",
source= [
"https://perinim.github.io/",
"https://perinim.github.io/cv/"
],
config=graph_config
)

result = smart_scraper_multi_lite_graph.run()
print(json.dumps(result, indent=4))

# ************************************************
# Get graph execution info
# ************************************************

graph_exec_info = smart_scraper_multi_lite_graph.get_execution_info()
print(prettify_exec_info(graph_exec_info))
31 changes: 31 additions & 0 deletions examples/groq/smart_scraper_lite_groq.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"""
Basic example of scraping pipeline using SmartScraper
"""
import os
import json
from dotenv import load_dotenv
from scrapegraphai.graphs import SmartScraperLiteGraph
from scrapegraphai.utils import prettify_exec_info

load_dotenv()

graph_config = {
"llm": {
"api_key": os.getenv("GROQ_API_KEY"),
"model": "mixtral-8x7b-32768",
},
"verbose": True,
"headless": False,
}

smart_scraper_lite_graph = SmartScraperLiteGraph(
prompt="Who is Marco Perini?",
source="https://perinim.github.io/",
config=graph_config
)

result = smart_scraper_lite_graph.run()
print(json.dumps(result, indent=4))

graph_exec_info = smart_scraper_lite_graph.get_execution_info()
print(prettify_exec_info(graph_exec_info))
31 changes: 31 additions & 0 deletions examples/huggingfacehub/smart_scraper_lite_huggingfacehub.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"""
Basic example of scraping pipeline using SmartScraper
"""
import os
import json
from dotenv import load_dotenv
from scrapegraphai.graphs import SmartScraperLiteGraph
from scrapegraphai.utils import prettify_exec_info

load_dotenv()

graph_config = {
"llm": {
"api_key": os.getenv("HUGGINGFACEHUB_API_TOKEN"),
"model": "huggingfacehub/meta-llama/Llama-2-70b-chat-hf",
},
"verbose": True,
"headless": False,
}

smart_scraper_lite_graph = SmartScraperLiteGraph(
prompt="Who is Marco Perini?",
source="https://perinim.github.io/",
config=graph_config
)

result = smart_scraper_lite_graph.run()
print(json.dumps(result, indent=4))

graph_exec_info = smart_scraper_lite_graph.get_execution_info()
print(prettify_exec_info(graph_exec_info))
30 changes: 30 additions & 0 deletions examples/local_models/smart_scraper_lite_ollama.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""
Basic example of scraping pipeline using SmartScraper
"""
import json
from scrapegraphai.graphs import SmartScraperLiteGraph
from scrapegraphai.utils import prettify_exec_info

graph_config = {
"llm": {
"model": "ollama/llama3.1",
"temperature": 0,
"format": "json",
"base_url": "http://localhost:11434",
},
"verbose": True,
"headless": False
}

smart_scraper_lite_graph = SmartScraperLiteGraph(
prompt="Who is Marco Perini?",
source="https://perinim.github.io/",
config=graph_config
)

result = smart_scraper_lite_graph.run()
print(json.dumps(result, indent=4))

graph_exec_info = smart_scraper_lite_graph.get_execution_info()
print(prettify_exec_info(graph_exec_info))
Loading

0 comments on commit b84883b

Please sign in to comment.