Python scraper based on AI
Python ai-crawlerai-scrapingai-searchcrawlerdata-extractionfirecrawl-alternativelarge-language-modelllmmarkdownragscrapingscraping-pythonweb-crawlerweb-crawlersweb-dataweb-data-extractionweb-scraperweb-scrapingweb-searchwebscraping
ad bedrocl
VinciGit00c0d26d61d787
diff --git a/examples/bedrock/smart_scraper_bedrock.py b/examples/bedrock/smart_scraper_bedrock.pynew file mode 100644index 00000000..fff586f2--- /dev/null+++ b/examples/bedrock/smart_scraper_bedrock.py@@ -0,0 +1,42 @@+"""+Smartscraper example on bedrock+"""+import boto3++from scrapegraphai.graphs import SmartScraperGraph++# 0a. Initialize session+# If not required delete it+session = boto3.Session(+ aws_access_key_id="...",+ aws_secret_access_key="...",+ aws_session_token="...",+ region_name="us-east-1"+)++# 0b. Initialize client+client = session.client("bedrock-runtime")++# 1. Define graph configuration+config = {+ "llm": {+ "client": client,+ "model": "bedrock/anthropic.claude-3-sonnet-20240229-v1:0",+ "temperature": 0.0,+ "format": "json"+ },+ "embeddings": {+ "client": client,+ "model": "bedrock/cohere.embed-multilingual-v3",+ },+}++# 2. Create graph instance+graph = SmartScraperGraph(+ prompt="List me all the articles",+ source="https://perinim.github.io/projects",+ config=config+)++# 3. Scrape away!+print(graph.run())diff --git a/examples/local_models/Ollama/smart_scraper_ollama.py b/examples/local_models/Ollama/smart_scraper_ollama.pyindex 02529e9e..babf4c2b 100644--- a/examples/local_models/Ollama/smart_scraper_ollama.py+++ b/examples/local_models/Ollama/smart_scraper_ollama.py@@ -9,7 +9,7 @@ from scrapegraphai.utils import prettify_exec_infograph_config = {"llm": {- "model": "ollama/llama3",+ "model": "ollama/mistral","temperature": 0,"format": "json", # Ollama needs the format to be specified explicitly# "base_url": "http://localhost:11434", # set ollama URL arbitrarily@@ -27,9 +27,9 @@ graph_config = {# ************************************************smart_scraper_graph = SmartScraperGraph(- prompt="List me all the projects with their description.",+ prompt="List me all the titles",# also accepts a string with the already downloaded HTML code- source="https://perinim.github.io/projects",+ source="https://www.wired.com/",config=graph_config)