Skip to content

Python scraper based on AI

Merge branch 'main' into main

Marco Vinciguerra02eed1ac9db0
diff --cc scrapegraphai/docloaders/browser_base.py
index 0d6a78c1,5d7beb7d..58bf9e9d
--- a/scrapegraphai/docloaders/browser_base.py
+++ b/scrapegraphai/docloaders/browser_base.py
@@@ -53,22 -49,7 +53,19 @@@ def browser_base_fetch(api_key: str, pr
browserbase = Browserbase(api_key=api_key, project_id=project_id)
result = []
- # Define the async fetch logic for individual links
- for l in link:
- result.append(browserbase.load(l, text_content=text_content))
+ async def _async_fetch_link(l):
+ return await asyncio.to_thread(browserbase.load, l, text_content=text_content)
+
+ if async_mode:
- # Asynchronously process each link
+ async def _async_browser_base_fetch():
+ for l in link:
+ result.append(await _async_fetch_link(l))
+ return result
+
- # Run the async fetch function
+ result = asyncio.run(_async_browser_base_fetch())
+ else:
- # Synchronous logic
+ for l in link:
+ result.append(browserbase.load(l, text_content=text_content))
+
+
return result