Skip to content

Commit 8f405ff

Browse files
author
Steven Thomas
committed
Add the ability to specify load state
1 parent 81f89d8 commit 8f405ff

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

scrapegraphai/docloaders/chromium.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ def __init__(
2929
backend: str = "playwright",
3030
headless: bool = True,
3131
proxy: Optional[Proxy] = None,
32+
load_state: str = "domcontentloaded",
3233
**kwargs: Any,
3334
):
3435
"""Initialize the loader with a list of URL paths.
@@ -55,6 +56,7 @@ def __init__(
5556
self.headless = headless
5657
self.proxy = parse_or_search_proxy(proxy) if proxy else None
5758
self.urls = urls
59+
self.load_state = load_state
5860

5961
async def ascrape_playwright(self, url: str) -> str:
6062
"""
@@ -81,6 +83,7 @@ async def ascrape_playwright(self, url: str) -> str:
8183
await Malenia.apply_stealth(context)
8284
page = await context.new_page()
8385
await page.goto(url)
86+
await page.wait_for_load_state(self.load_state)
8487
results = await page.content() # Simply get the HTML content
8588
logger.info("Content scraped")
8689
except Exception as e:

0 commit comments

Comments
 (0)