Python scraper based on AI
Python ai-crawlerai-scrapingai-searchcrawlerdata-extractionfirecrawl-alternativelarge-language-modelllmmarkdownragscrapingscraping-pythonweb-crawlerweb-crawlersweb-dataweb-data-extractionweb-scraperweb-scrapingweb-searchwebscraping
add extras
Marco Vinciguerraec0bd232104b
diff --git a/examples/extras/.env.example b/examples/extras/.env.examplenew file mode 100644index 00000000..dc01444e--- /dev/null+++ b/examples/extras/.env.example@@ -0,0 +1,4 @@+OPENAI_API_KEY="YOUR_OPENAI_API_KEY"+BROWSER_BASE_PROJECT_ID="YOUR_BROWSER_BASE_PROJECT_ID"+BROWSER_BASE_API_KEY="YOUR_BROWSERBASE_API_KEY"+SCRAPE_DO_API_KEY="YOUR_SCRAPE_DO_API_KEY"\ No newline at end of filediff --git a/examples/extras/Savedscreenshots/test_image.jpeg b/examples/extras/Savedscreenshots/test_image.jpegnew file mode 100644index 00000000..159625bcBinary files /dev/null and b/examples/extras/Savedscreenshots/test_image.jpeg differdiff --git a/examples/extras/authenticated_playwright.py b/examples/extras/authenticated_playwright.pynew file mode 100644index 00000000..a4926bc7--- /dev/null+++ b/examples/extras/authenticated_playwright.py@@ -0,0 +1,93 @@+"""+Example leveraging a state file containing session cookies which+might be leveraged to authenticate to a website and scrape protected+content.+"""++import os+import random+from dotenv import load_dotenv++# import playwright so we can use it to create the state file+from playwright.async_api import async_playwright++from scrapegraphai.graphs import OmniScraperGraph+from scrapegraphai.utils import prettify_exec_info++load_dotenv()++# ************************************************+# Leveraging Playwright external to the invocation of the graph to+# login and create the state file+# ************************************************+++# note this is just an example and probably won't actually work on+# LinkedIn, the implementation of the login is highly dependent on the website+async def do_login():+ async with async_playwright() as playwright:+ browser = await playwright.chromium.launch(+ timeout=30000,+ headless=False,+ slow_mo=random.uniform(500, 1500),+ )+ page = await browser.new_page()++ # very basic implementation of a login, in reality it may be trickier+ await page.goto("https://www.linkedin.com/login")+ await page.get_by_label("Email or phone").fill("some_bloke@some_domain.com")+ await page.get_by_label("Password").fill("test1234")+ await page.get_by_role("button", name="Sign in").click()+ await page.wait_for_timeout(3000)++ # assuming a successful login, we save the cookies to a file+ await page.context.storage_state(path="./state.json")+++async def main():+ await do_login()++ # ************************************************+ # Define the configuration for the graph+ # ************************************************++ openai_api_key = os.getenv("OPENAI_APIKEY")++ graph_config = {+ "llm": {+ "api_key": openai_api_key,+ "model": "openai/gpt-4o",+ },+ "max_images": 10,+ "headless": False,+ # provide the path to the state file+ "storage_state": "./state.json",+ }++ # ************************************************+ # Create the OmniScraperGraph instance and run it+ # ************************************************++ omni_scraper_graph = OmniScraperGraph(+ prompt="List me all the projects with their description.",+ source="https://www.linkedin.com/feed/",+ config=graph_config,+ )++ # the storage_state is used to load the cookies from the state file+ # so we are authenticated and able to scrape protected content+ result = omni_scraper_graph.run()+ print(result)++ # ************************************************+ # Get graph execution info+ # ************************************************++ graph_exec_info = omni_scraper_graph.get_execution_info()+ print(prettify_exec_info(graph_exec_info))+++if __name__ == "__main__":+ import asyncio++ asyncio.run(main())diff --git a/examples/extras/browser_base_integration.py b/examples/extras/browser_base_integration.pynew file mode 100644index 00000000..7030e101--- /dev/null+++ b/examples/extras/browser_base_integration.py@@ -0,0 +1,49 @@+"""+Basic example of scraping pipeline using SmartScraper+"""++import os+import json+from dotenv import load_dotenv+from scrapegraphai.graphs import SmartScraperGraph+from scrapegraphai.utils import prettify_exec_info++load_dotenv()++# ************************************************+# Define the configuration for the graph+# ************************************************+++graph_config = {+ "llm": {+ "api_key": os.getenv("OPENAI_API_KEY"),+ "model": "openai/gpt-4o",+ },+ "browser_base": {+ "api_key": os.getenv("BROWSER_BASE_API_KEY"),+ "project_id": os.getenv("BROWSER_BASE_PROJECT_ID"),+ },+ "verbose": True,+ "headless": False,+}++# ************************************************+# Create the SmartScraperGraph instance and run it+# ************************************************++smart_scraper_graph = SmartScraperGraph(+ prompt="List me what does the company do, the name and a contact email.",+ source="https://scrapegraphai.com/",+ config=graph_config+)++result = smart_scraper_graph.run()+print(json.dumps(result, indent=4))++# ************************************************+# Get graph execution info+# ************************************************++graph_exec_info = smart_scraper_graph.get_execution_info()+print(prettify_exec_info(graph_exec_info))diff --git a/examples/extras/chromium_selenium.py b/examples/extras/chromium_selenium.pynew file mode 100644index 00000000..fba530d4--- /dev/null+++ b/examples/extras/chromium_selenium.py@@ -0,0 +1,119 @@+import asyncio+import os+import json+from dotenv import load_dotenv+from scrapegraphai.docloaders.chromium import ChromiumLoader # Import your ChromiumLoader class+from scrapegraphai.graphs import SmartScraperGraph+from scrapegraphai.utils import prettify_exec_info+from aiohttp import ClientError++# Load environment variables for API keys+load_dotenv()++# ************************************************+# Define function to analyze content with ScrapegraphAI+# ************************************************+async def analyze_content_with_scrapegraph(content: str):+ """+ Analyze scraped content using ScrapegraphAI.++ Args:+ content (str): The scraped HTML or text content.++ Returns:+ dict: The result from ScrapegraphAI analysis.+ """+ try:+ # Initialize ScrapegraphAI SmartScraperGraph+ smart_scraper = SmartScraperGraph(+ prompt="Summarize the main content of this webpage and extract any contact information.",+ source=content, # Pass the content directly+ config={+ "llm": {+ "api_key": os.getenv("OPENAI_API_KEY"),+ "model": "openai/gpt-4o",+ },+ "verbose": True+ }+ )+ result = smart_scraper.run()+ return result+ except Exception as e:+ print(f"β ScrapegraphAI analysis failed: {e}")+ return {"error": str(e)}++# ************************************************+# Test scraper and ScrapegraphAI pipeline+# ************************************************+async def test_scraper_with_analysis(scraper: ChromiumLoader, urls: list):+ """+ Test scraper for the given backend and URLs, then analyze content with ScrapegraphAI.++ Args:+ scraper (ChromiumLoader): The ChromiumLoader instance.+ urls (list): A list of URLs to scrape.+ """+ for url in urls:+ try:+ print(f"\nπ Scraping: {url} using {scraper.backend}...")+ result = await scraper.scrape(url)++ if "Error" in result or not result.strip():+ print(f"β Failed to scrape {url}: {result}")+ else:+ print(f"β Successfully scraped {url}. Content (first 200 chars): {result[:200]}")++ # Pass scraped content to ScrapegraphAI for analysis+ print("π€ Analyzing content with ScrapegraphAI...")+ analysis_result = await analyze_content_with_scrapegraph(result)+ print("π Analysis Result:")+ print(json.dumps(analysis_result, indent=4))++ except ClientError as ce:+ print(f"β Network error while scraping {url}: {ce}")+ except Exception as e:+ print(f"β Unexpected error while scraping {url}: {e}")++# ************************************************+# Main Execution+# ************************************************+async def main():+ urls_to_scrape = [+ "https://example.com",+ "https://www.python.org",+ "https://invalid-url.test"+ ]++ # Test with Playwright backend+ print("\n--- Testing Playwright Backend ---")+ try:+ scraper_playwright_chromium = ChromiumLoader(urls=urls_to_scrape, backend="playwright", headless=True, browser_name = "chromium")+ await test_scraper_with_analysis(scraper_playwright_chromium, urls_to_scrape)++ scraper_playwright_firefox = ChromiumLoader(urls=urls_to_scrape, backend="playwright", headless=True, browser_name = "firefox")+ await test_scraper_with_analysis(scraper_playwright_firefox, urls_to_scrape)+ except ImportError as ie:+ print(f"β Playwright ImportError: {ie}")+ except Exception as e:+ print(f"β Error initializing Playwright ChromiumLoader: {e}")++ # Test with Selenium backend+ print("\n--- Testing Selenium Backend ---")+ try:+ scraper_selenium_chromium = ChromiumLoader(urls=urls_to_scrape, backend="selenium", headless=True, browser_name = "chromium")+ await test_scraper_with_analysis(scraper_selenium_chromium, urls_to_scrape)++ scraper_selenium_firefox = ChromiumLoader(urls=urls_to_scrape, backend="selenium", headless=True, browser_name = "firefox")+ await test_scraper_with_analysis(scraper_selenium_firefox, urls_to_scrape)+ except ImportError as ie:+ print(f"β Selenium ImportError: {ie}")+ except Exception as e:+ print(f"β Error initializing Selenium ChromiumLoader: {e}")++if __name__ == "__main__":+ try:+ asyncio.run(main())+ except KeyboardInterrupt:+ print("β Program interrupted by user.")+ except Exception as e:+ print(f"β Program crashed: {e}")diff --git a/examples/extras/cond_smartscraper_usage.py b/examples/extras/cond_smartscraper_usage.pynew file mode 100644index 00000000..54c40712--- /dev/null+++ b/examples/extras/cond_smartscraper_usage.py@@ -0,0 +1,38 @@+"""+Basic example of scraping pipeline using SmartScraperMultiConcatGraph with Groq+"""++import os+import json+from dotenv import load_dotenv+from scrapegraphai.graphs import SmartScraperGraph++load_dotenv()++# ************************************************+# Define the configuration for the graph+# ************************************************++graph_config = {+ "llm": {+ "api_key": os.getenv("GROQ_APIKEY"),+ "model": "groq/gemma-7b-it",+ },+ "verbose": True,+ "headless": True,+ "reattempt": True #Setting this to True will allow the graph to reattempt the scraping process+}++# *******************************************************+# Create the SmartScraperMultiCondGraph instance and run it+# *******************************************************++multiple_search_graph = SmartScraperGraph(+ prompt="Who is Marco Perini?",+ source="https://perinim.github.io/",+ schema=None,+ config=graph_config+)++result = multiple_search_graph.run()+print(json.dumps(result, indent=4))diff --git a/examples/extras/conditional_usage.py b/examples/extras/conditional_usage.pynew file mode 100644index 00000000..d3152bed--- /dev/null+++ b/examples/extras/conditional_usage.py@@ -0,0 +1,41 @@+"""+Basic example of scraping pipeline using SmartScraperMultiConcatGraph with Groq+"""++import os+import json+from dotenv import load_dotenv+from scrapegraphai.graphs import SmartScraperMultiGraph++load_dotenv()++# ************************************************+# Define the configuration for the graph+# ************************************************++graph_config = {+ "llm": {+ "api_key": os.getenv("OPENAI_API_KEY"),+ "model": "openai/gpt-4o",+ },++ "verbose": True,+ "headless": False,+}++# *******************************************************+# Create the SmartScraperMultiCondGraph instance and run it+# *******************************************************++multiple_search_graph = SmartScraperMultiGraph(+ prompt="Who is Marco Perini?",+ source=[+ "https://perinim.github.io/",+ "https://perinim.github.io/cv/"+ ],+ schema=None,+ config=graph_config+)++result = multiple_search_graph.run()+print(json.dumps(result, indent=4))diff --git a/examples/extras/custom_prompt.py b/examples/extras/custom_prompt.pynew file mode 100644index 00000000..7def35a3--- /dev/null+++ b/examples/extras/custom_prompt.py@@ -0,0 +1,50 @@+"""+Basic example of scraping pipeline using SmartScraper+"""+import os+import json+from dotenv import load_dotenv+from scrapegraphai.graphs import SmartScraperGraph+from scrapegraphai.utils import prettify_exec_info++load_dotenv()+++# ************************************************+# Define the configuration for the graph+# ************************************************++openai_key = os.getenv("OPENAI_APIKEY")++prompt = "Some more info"++graph_config = {+ "llm": {+ "api_key": openai_key,+ "model": "openai/gpt-3.5-turbo",+ },+ "additional_info": prompt,+ "verbose": True,+ "headless": False,+}++# ************************************************+# Create the SmartScraperGraph instance and run it+# ************************************************++smart_scraper_graph = SmartScraperGraph(+ prompt="List me all the projects with their description",+ # 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(json.dumps(result, indent=4))++# ************************************************+# Get graph execution info+# ************************************************++graph_exec_info = smart_scraper_graph.get_execution_info()+print(prettify_exec_info(graph_exec_info))diff --git a/examples/extras/example.yml b/examples/extras/example.ymlnew file mode 100644index 00000000..fd5713c7--- /dev/null+++ b/examples/extras/example.yml@@ -0,0 +1,15 @@+{+ "llm": {+ "model": "ollama/llama3",+ "temperature": 0,+ "format": "json",+ # "base_url": "http://localhost:11434",+ },+ "embeddings": {+ "model": "ollama/nomic-embed-text",+ "temperature": 0,+ # "base_url": "http://localhost:11434",+ },+ "verbose": true,+ "headless": false+}\ No newline at end of filediff --git a/examples/extras/force_mode.py b/examples/extras/force_mode.pynew file mode 100644index 00000000..85593032--- /dev/null+++ b/examples/extras/force_mode.py@@ -0,0 +1,54 @@+"""+Basic example of scraping pipeline using SmartScraper+"""++import os+from dotenv import load_dotenv+from scrapegraphai.graphs import SmartScraperGraph+from scrapegraphai.utils import prettify_exec_info++load_dotenv()+++# ************************************************+# Define the configuration for the graph+# ************************************************++openai_key = os.getenv("OPENAI_APIKEY")++graph_config = {+ "llm": {+ "model": "ollama/llama3",+ "temperature": 0,+ # "format": "json", # Ollama needs the format to be specified explicitly+ # "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+ },+ "force": True,+ "caching": True+}++# ************************************************+# Create the SmartScraperGraph instance and run it+# ************************************************++smart_scraper_graph = SmartScraperGraph(+ prompt="List me all the projects with their description.",+ # 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)++# ************************************************+# Get graph execution info+# ************************************************++graph_exec_info = smart_scraper_graph.get_execution_info()+print(prettify_exec_info(graph_exec_info))diff --git a/examples/extras/html_mode.py b/examples/extras/html_mode.pynew file mode 100644index 00000000..6e2670a0--- /dev/null+++ b/examples/extras/html_mode.py@@ -0,0 +1,49 @@+"""+Basic example of scraping pipeline using SmartScraper+By default smart scraper converts in md format the+code. If you want to just use the original code, you have+to specify in the confi+"""++import os+import json+from dotenv import load_dotenv+from scrapegraphai.graphs import SmartScraperGraph+from scrapegraphai.utils import prettify_exec_info++load_dotenv()++# ************************************************+# Define the configuration for the graph+# ************************************************+++graph_config = {+ "llm": {+ "api_key": os.getenv("OPENAI_API_KEY"),+ "model": "openai/gpt-4o",+ },+ "html_mode": True,+ "verbose": True,+ "headless": False,+}++# ************************************************+# Create the SmartScraperGraph instance and run it+# ************************************************++smart_scraper_graph = SmartScraperGraph(+ prompt="List me what does the company do, the name and a contact email.",+ source="https://scrapegraphai.com/",+ config=graph_config+)++result = smart_scraper_graph.run()+print(json.dumps(result, indent=4))++# ************************************************+# Get graph execution info+# ************************************************++graph_exec_info = smart_scraper_graph.get_execution_info()+print(prettify_exec_info(graph_exec_info))diff --git a/examples/extras/load_yml.py b/examples/extras/load_yml.pynew file mode 100644index 00000000..974ba4d5--- /dev/null+++ b/examples/extras/load_yml.py@@ -0,0 +1,32 @@+"""+Basic example of scraping pipeline using SmartScraper+"""+import yaml+from scrapegraphai.graphs import SmartScraperGraph+from scrapegraphai.utils import prettify_exec_info++# ************************************************+# Define the configuration for the graph+# ************************************************+with open("example.yml", 'r') as file:+ graph_config = yaml.safe_load(file)++# ************************************************+# Create the SmartScraperGraph instance and run it+# ************************************************++smart_scraper_graph = SmartScraperGraph(+ prompt="List me all the titles",+ source="https://sport.sky.it/nba?gr=www",+ config=graph_config+)++result = smart_scraper_graph.run()+print(result)++# ************************************************+# Get graph execution info+# ************************************************++graph_exec_info = smart_scraper_graph.get_execution_info()+print(prettify_exec_info(graph_exec_info))diff --git a/examples/extras/no_cut.py b/examples/extras/no_cut.pynew file mode 100644index 00000000..71bfad86--- /dev/null+++ b/examples/extras/no_cut.py@@ -0,0 +1,43 @@+"""+This example shows how to do not process the html code in the fetch phase+"""++import os, json+from scrapegraphai.graphs import SmartScraperGraph+from scrapegraphai.utils import prettify_exec_info+++# ************************************************+# Define the configuration for the graph+# ************************************************+++graph_config = {+ "llm": {+ "api_key": "s",+ "model": "openai/gpt-3.5-turbo",+ },+ "cut": False,+ "verbose": True,+ "headless": False,+}++# ************************************************+# Create the SmartScraperGraph instance and run it+# ************************************************++smart_scraper_graph = SmartScraperGraph(+ prompt="Extract me the python code inside the page",+ source="https://www.exploit-db.com/exploits/51447",+ config=graph_config+)++result = smart_scraper_graph.run()+print(json.dumps(result, indent=4))++# ************************************************+# Get graph execution info+# ************************************************++graph_exec_info = smart_scraper_graph.get_execution_info()+print(prettify_exec_info(graph_exec_info))diff --git a/examples/extras/proxy_rotation.py b/examples/extras/proxy_rotation.pynew file mode 100644index 00000000..adfb87ed--- /dev/null+++ b/examples/extras/proxy_rotation.py@@ -0,0 +1,48 @@+"""+Basic example of scraping pipeline using SmartScraper+"""++from scrapegraphai.graphs import SmartScraperGraph+from scrapegraphai.utils import prettify_exec_info+++# ************************************************+# Define the configuration for the graph+# ************************************************++graph_config = {+ "llm": {+ "api_key": "API_KEY",+ "model": "openai/gpt-3.5-turbo",+ },+ "loader_kwargs": {+ "proxy" : {+ "server": "http:/**********",+ "username": "********",+ "password": "***",+ },+ },+ "verbose": True,+ "headless": False,+}++# ************************************************+# Create the SmartScraperGraph instance and run it+# ************************************************++smart_scraper_graph = SmartScraperGraph(+ prompt="List me all the projects with their description",+ # 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)++# ************************************************+# Get graph execution info+# ************************************************++graph_exec_info = smart_scraper_graph.get_execution_info()+print(prettify_exec_info(graph_exec_info))diff --git a/examples/extras/rag_caching.py b/examples/extras/rag_caching.pynew file mode 100644index 00000000..df73d2b4--- /dev/null+++ b/examples/extras/rag_caching.py@@ -0,0 +1,46 @@+"""+Basic example of scraping pipeline using SmartScraper+"""++import os+from dotenv import load_dotenv+from scrapegraphai.graphs import SmartScraperGraph+from scrapegraphai.utils import prettify_exec_info++load_dotenv()+++# ************************************************+# Define the configuration for the graph+# ************************************************++openai_key = os.getenv("OPENAI_APIKEY")++graph_config = {+ "llm": {+ "api_key": openai_key,+ "model": "openai/gpt-3.5-turbo",+ },+ "caching": True+}++# ************************************************+# Create the SmartScraperGraph instance and run it+# ************************************************++smart_scraper_graph = SmartScraperGraph(+ prompt="List me all the projects with their description.",+ # 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)++# ************************************************+# Get graph execution info+# ************************************************++graph_exec_info = smart_scraper_graph.get_execution_info()+print(prettify_exec_info(graph_exec_info))\ No newline at end of filediff --git a/examples/extras/reasoning.py b/examples/extras/reasoning.pynew file mode 100644index 00000000..80e57faa--- /dev/null+++ b/examples/extras/reasoning.py@@ -0,0 +1,46 @@+"""+Basic example of scraping pipeline using SmartScraper+"""++import os+import json+from dotenv import load_dotenv+from scrapegraphai.graphs import SmartScraperGraph+from scrapegraphai.utils import prettify_exec_info++load_dotenv()++# ************************************************+# Define the configuration for the graph+# ************************************************+++graph_config = {+ "llm": {+ "api_key": os.getenv("OPENAI_API_KEY"),+ "model": "openai/gpt-4o",+ },+ "reasoning": True,+ "verbose": True,+ "headless": False,+}++# ************************************************+# Create the SmartScraperGraph instance and run it+# ************************************************++smart_scraper_graph = SmartScraperGraph(+ prompt="List me what does the company do, the name and a contact email.",+ source="https://scrapegraphai.com/",+ config=graph_config+)++result = smart_scraper_graph.run()+print(json.dumps(result, indent=4))++# ************************************************+# Get graph execution info+# ************************************************++graph_exec_info = smart_scraper_graph.get_execution_info()+print(prettify_exec_info(graph_exec_info))diff --git a/examples/extras/scrape_do.py b/examples/extras/scrape_do.pynew file mode 100644index 00000000..45026f21--- /dev/null+++ b/examples/extras/scrape_do.py@@ -0,0 +1,40 @@+"""+Basic example of scraping pipeline using SmartScraper+"""++import os+import json+from dotenv import load_dotenv+from scrapegraphai.graphs import SmartScraperGraph++load_dotenv()++# ************************************************+# Define the configuration for the graph+# ************************************************+++graph_config = {+ "llm": {+ "api_key": os.getenv("OPENAI_API_KEY"),+ "model": "openai/gpt-4o",+ },+ "scrape_do": {+ "api_key": os.getenv("SCRAPE_DO_API_KEY"),+ },+ "verbose": True,+ "headless": False,+}++# ************************************************+# Create the SmartScraperGraph instance and run it+# ************************************************++smart_scraper_graph = SmartScraperGraph(+ prompt="List me all the projects",+ source="https://perinim.github.io/projects/",+ config=graph_config+)++result = smart_scraper_graph.run()+print(json.dumps(result, indent=4))diff --git a/examples/extras/screenshot_scaping.py b/examples/extras/screenshot_scaping.pynew file mode 100644index 00000000..439c2a0c--- /dev/null+++ b/examples/extras/screenshot_scaping.py@@ -0,0 +1,32 @@+"""+example of scraping with screenshots+"""+import asyncio+from scrapegraphai.utils.screenshot_scraping import (take_screenshot,+ select_area_with_opencv,+ crop_image, detect_text)++# STEP 1: Take a screenshot+image = asyncio.run(take_screenshot(+ url="https://colab.google/",+ save_path="Savedscreenshots/test_image.jpeg",+ quality = 50+))++# STEP 2 (Optional): Select an area of the image which you want to use for text detection.+LEFT, TOP, RIGHT, BOTTOM = select_area_with_opencv(image)+print("LEFT: ", LEFT, " TOP: ", TOP, " RIGHT: ", RIGHT, " BOTTOM: ", BOTTOM)++# STEP 3 (Optional): Crop the image.+# Note: If any of the coordinates (LEFT, TOP, RIGHT, BOTTOM) is None,+# it will be set to the corresponding edge of the image.+cropped_image = crop_image(image, LEFT=LEFT, RIGHT=RIGHT,TOP=TOP,BOTTOM=BOTTOM)++# STEP 4: Detect text+TEXT = detect_text(+ cropped_image, # The image to detect text from+ languages = ["en"] # The languages to detect text in+)++print("DETECTED TEXT: ")+print(TEXT)diff --git a/examples/extras/serch_graph_scehma.py b/examples/extras/serch_graph_scehma.pynew file mode 100644index 00000000..66c47a33--- /dev/null+++ b/examples/extras/serch_graph_scehma.py@@ -0,0 +1,43 @@+"""+Example of Search Graph+"""++import os+from dotenv import load_dotenv+from scrapegraphai.graphs import SearchGraph+from pydantic import BaseModel, Field+from typing import List+load_dotenv()++# ************************************************+# Define the configuration for the graph+# ************************************************+class CeoName(BaseModel):+ ceo_name: str = Field(description="The name and surname of the ceo")++class Ceos(BaseModel):+ names: List[CeoName]++openai_key = os.getenv("OPENAI_APIKEY")++graph_config = {+ "llm": {+ "api_key": openai_key,+ "model": "openai/gpt-4o",+ },+ "max_results": 2,+ "verbose": True,+}++# ************************************************+# Create the SearchGraph instance and run it+# ************************************************++search_graph = SearchGraph(+ prompt=f"Who is the ceo of Appke?",+ schema = Ceos,+ config=graph_config,+)++result = search_graph.run()+print(result)diff --git a/examples/extras/slow_mo.py b/examples/extras/slow_mo.pynew file mode 100644index 00000000..55b40cd7--- /dev/null+++ b/examples/extras/slow_mo.py@@ -0,0 +1,48 @@+"""+Basic example of scraping pipeline using SmartScraper+"""+from scrapegraphai.graphs import SmartScraperGraph+from scrapegraphai.utils import prettify_exec_info+# ************************************************+# Define the configuration for the graph+# ************************************************++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 arbitrarily+ },+ "embeddings": {+ "model": "ollama/nomic-embed-text",+ "temperature": 0,+ # "base_url": "http://localhost:11434", # set ollama URL arbitrarily+ },+ "loader_kwargs": {+ "slow_mo": 10000+ },+ "verbose": True,+ "headless": False+}++# ************************************************+# Create the SmartScraperGraph instance and run it+# ************************************************++smart_scraper_graph = SmartScraperGraph(+ prompt="List me all the titles",+ # also accepts a string with the already downloaded HTML code+ source="https://www.wired.com/",+ config=graph_config+)++result = smart_scraper_graph.run()+print(result)++# ************************************************+# Get graph execution info+# ************************************************++graph_exec_info = smart_scraper_graph.get_execution_info()+print(prettify_exec_info(graph_exec_info))\ No newline at end of filediff --git a/examples/extras/undected_playwright.py b/examples/extras/undected_playwright.pynew file mode 100644index 00000000..999fe42e--- /dev/null+++ b/examples/extras/undected_playwright.py@@ -0,0 +1,47 @@+"""+Basic example of scraping pipeline using SmartScraper+"""++import os+from dotenv import load_dotenv+from scrapegraphai.graphs import SmartScraperGraph+from scrapegraphai.utils import prettify_exec_info++load_dotenv()++# ************************************************+# Define the configuration for the graph+# ************************************************++groq_key = os.getenv("GROQ_APIKEY")++graph_config = {+ "llm": {+ "model": "groq/gemma-7b-it",+ "api_key": groq_key,+ "temperature": 0+ },+ "headless": False,+ "backend": "undetected_chromedriver"+}++# ************************************************+# Create the SmartScraperGraph instance and run it+# ************************************************++smart_scraper_graph = SmartScraperGraph(+ prompt="List me all the projects with their description.",+ # 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)++# ************************************************+# Get graph execution info+# ************************************************++graph_exec_info = smart_scraper_graph.get_execution_info()+print(prettify_exec_info(graph_exec_info))