Correctly get page content after JS Execution

- Thanks for @AbdullahY36 for the heads-up.

**Update reference** https://developer.mozilla.org/en-US/docs/Web/API/Document/DOMContentLoaded_event
This commit is contained in:
Karim shoair
2024-11-10 16:11:46 +02:00
parent 43045e3eb2
commit 239e2c73bf
3 changed files with 13 additions and 7 deletions
+3 -2
View File
@@ -199,7 +199,8 @@ class PlaywrightEngine:
page.add_init_script(path=js_bypass_path('screen_props.js'))
page.add_init_script(path=js_bypass_path('playwright_fingerprint.js'))
res = page.goto(url, referer=generate_convincing_referer(url) if self.google_search else None, wait_until="domcontentloaded")
res = page.goto(url, referer=generate_convincing_referer(url) if self.google_search else None)
page.wait_for_load_state(state="domcontentloaded")
if self.network_idle:
page.wait_for_load_state('networkidle')
@@ -217,7 +218,7 @@ class PlaywrightEngine:
response = Response(
url=res.url,
text=res.text(),
text=page.content(),
content=res.body(),
status=res.status,
reason=res.status_text,