Skip to content

Add the ability to specify load state #368

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions scrapegraphai/docloaders/chromium.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def __init__(
backend: str = "playwright",
headless: bool = True,
proxy: Optional[Proxy] = None,
load_state: str = "domcontentloaded",
**kwargs: Any,
):
"""Initialize the loader with a list of URL paths.
Expand All @@ -55,6 +56,7 @@ def __init__(
self.headless = headless
self.proxy = parse_or_search_proxy(proxy) if proxy else None
self.urls = urls
self.load_state = load_state

async def ascrape_playwright(self, url: str) -> str:
"""
Expand All @@ -81,6 +83,7 @@ async def ascrape_playwright(self, url: str) -> str:
await Malenia.apply_stealth(context)
page = await context.new_page()
await page.goto(url)
await page.wait_for_load_state(self.load_state)
results = await page.content() # Simply get the HTML content
logger.info("Content scraped")
except Exception as e:
Expand Down
3 changes: 3 additions & 0 deletions scrapegraphai/nodes/search_link_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ def execute(self, state: dict) -> dict:

Assume relevance broadly, including any links that might be related or potentially useful
in relation to the task.

Sort it in order of importance, the first one should be the most important one, the last one
the least important

Please list only valid URLs and make sure to err on the side of inclusion if it's uncertain
whether the content at the link is directly relevant.
Expand Down
Loading