Python scraper based on AI
Python ai-crawlerai-scrapingai-searchcrawlerdata-extractionfirecrawl-alternativelarge-language-modelllmmarkdownragscrapingscraping-pythonweb-crawlerweb-crawlersweb-dataweb-data-extractionweb-scraperweb-scrapingweb-searchwebscraping
feat: undected_chromedriver support
ekinsenler80ece2179ac4
diff --git a/examples/groq/smart_scraper_groq.py b/examples/groq/smart_scraper_groq.pyindex ab38edc0..999fe42e 100644--- a/examples/groq/smart_scraper_groq.py+++ b/examples/groq/smart_scraper_groq.py@@ -21,7 +21,8 @@ graph_config = {"api_key": groq_key,"temperature": 0},- "headless": False+ "headless": False,+ "backend": "undetected_chromedriver"}# ************************************************diff --git a/scrapegraphai/docloaders/chromium.py b/scrapegraphai/docloaders/chromium.pyindex cb0cfd9a..084e3e43 100644--- a/scrapegraphai/docloaders/chromium.py+++ b/scrapegraphai/docloaders/chromium.py@@ -61,6 +61,28 @@ class ChromiumLoader(BaseLoader):self.urls = urlsself.load_state = load_state+ async def ascrape_undetected_chromedriver(self, url: str) -> str:+ """+ Asynchronously scrape the content of a given URL using undetected chrome with Selenium.++ Args:+ url (str): The URL to scrape.++ Returns:+ str: The scraped HTML content or an error message if an exception occurs.++ """+ import undetected_chromedriver as uc++ logger.info(f"Starting scraping with {self.backend}...")+ results = ""+ try:+ driver = uc.Chrome()+ results = driver.get(url).page_content+ except Exception as e:+ results = f"Error: {e}"+ return results+async def ascrape_playwright(self, url: str) -> str:"""Asynchronously scrape the content of a given URL using Playwright's async API.@@ -75,7 +97,7 @@ class ChromiumLoader(BaseLoader):from playwright.async_api import async_playwrightfrom undetected_playwright import Malenia- logger.info("Starting scraping...")+ logger.info(f"Starting scraping with {self.backend}...")results = ""async with async_playwright() as p:browser = await p.chromium.launch(