Skip to content

🕷️ The BEST Web Scraping framework that handles everything from a single request to a full-scale crawl! Don't be shy, join here: https://discord.gg/EMgGbDceNQ and follow here for daily tips and tricks: https://x.com/Scrapling_dev

fix: Stop removing browser default page

Karim shoair7a7097b77575
diff --git a/scrapling/engines/_browsers/_camoufox.py b/scrapling/engines/_browsers/_camoufox.py
index 6e0bc1e..ad515ca 100644
--- a/scrapling/engines/_browsers/_camoufox.py
+++ b/scrapling/engines/_browsers/_camoufox.py
@@ -173,10 +173,6 @@ class StealthySession(StealthySessionMixin, SyncSession):
**self.launch_options
)
- # Get the default page and close it
- default_page = self.context.pages[0]
- default_page.close()
-
if self.init_script: # pragma: no cover
self.context.add_init_script(path=self.init_script)
@@ -482,10 +478,6 @@ class AsyncStealthySession(StealthySessionMixin, AsyncSession):
**self.launch_options
)
- # Get the default page and close it
- default_page = self.context.pages[0]
- await default_page.close()
-
if self.init_script: # pragma: no cover
await self.context.add_init_script(path=self.init_script)
diff --git a/scrapling/engines/_browsers/_controllers.py b/scrapling/engines/_browsers/_controllers.py
index 07efee2..70b3771 100644
--- a/scrapling/engines/_browsers/_controllers.py
+++ b/scrapling/engines/_browsers/_controllers.py
@@ -168,10 +168,6 @@ class DynamicSession(DynamicSessionMixin, SyncSession):
else:
self.context = self.playwright.chromium.launch_persistent_context(user_data_dir="", **self.launch_options)
- # Get the default page and close it
- default_page = self.context.pages[0]
- default_page.close()
-
if self.init_script: # pragma: no cover
self.context.add_init_script(path=self.init_script)
@@ -421,10 +417,6 @@ class AsyncDynamicSession(DynamicSessionMixin, AsyncSession):
user_data_dir="", **self.launch_options
)
- # Get the default page and close it
- default_page = self.context.pages[0]
- await default_page.close()
-
if self.init_script: # pragma: no cover
await self.context.add_init_script(path=self.init_script)