Skip to content

Commit 6c5f7bb

Browse files
authored
fix: add null check for document.body when reading scrollHeight
On some pages document.body can be null (non-standard DOM structure or early script execution). Accessing document.body.scrollHeight caused errors in these cases.
1 parent cfa2fae commit 6c5f7bb

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

scrapegraphai/docloaders/chromium.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ async def ascrape_playwright_scroll(
265265

266266
while True:
267267
current_height = await page.evaluate(
268-
"document.body.scrollHeight"
268+
"document.body ? document.body.scrollHeight : document.documentElement.scrollHeight"
269269
)
270270
heights.append(current_height)
271271
heights = heights[

0 commit comments

Comments
 (0)