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

StealthyFetcher - The option to drop unnecessary resources requests for speed boost

Karim shoairb32e1203f21f
diff --git a/scrapling/engines/camo.py b/scrapling/engines/camo.py
index 9e20914..b2cec20 100644
--- a/scrapling/engines/camo.py
+++ b/scrapling/engines/camo.py
@@ -5,6 +5,7 @@ from scrapling.engines.toolbelt import (
Response,
do_nothing,
get_os_name,
+ intercept_route,
check_type_validity,
generate_convincing_referer,
)
@@ -16,6 +17,7 @@ class CamoufoxEngine:
def __init__(
self, headless: Union[bool, str] = True,
block_images: Optional[bool] = False,
+ disable_resources: Optional[bool] = False,
block_webrtc: Optional[bool] = False,
allow_webgl: Optional[bool] = False,
network_idle: Optional[bool] = False,
@@ -27,6 +29,7 @@ class CamoufoxEngine:
):
self.headless = headless
self.block_images = bool(block_images)
+ self.disable_resources = bool(disable_resources)
self.block_webrtc = bool(block_webrtc)
self.allow_webgl = bool(allow_webgl)
self.network_idle = bool(network_idle)
@@ -52,6 +55,9 @@ class CamoufoxEngine:
page = browser.new_page()
page.set_default_navigation_timeout(self.timeout)
page.set_default_timeout(self.timeout)
+ if self.disable_resources:
+ page.route("**/*", intercept_route)
+
res = page.goto(url, referer=generate_convincing_referer(url))
page.wait_for_load_state(state="load")
page.wait_for_load_state(state="domcontentloaded")