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

perf: force ad blocking on the MCP server and when the AI mode is activated on CLI

Karim shoairad6fd5284553
diff --git a/scrapling/cli.py b/scrapling/cli.py
index 3327dcb..47056d9 100644
--- a/scrapling/cli.py
+++ b/scrapling/cli.py
@@ -53,6 +53,8 @@ def __Request_and_Save(
if not output_path.is_absolute():
output_path = Path.cwd() / output_file
+ if ai_targeted:
+ kwargs.setdefault("block_ads", True)
response = fetcher_func(url, **kwargs)
Convertor.write_content_to_file(response, str(output_path), css_selector, main_content_only=ai_targeted)
log.info(f"Content successfully saved to '{output_path}'")
diff --git a/scrapling/core/ai.py b/scrapling/core/ai.py
index 9b33821..060cb20 100644
--- a/scrapling/core/ai.py
+++ b/scrapling/core/ai.py
@@ -183,6 +183,7 @@ class ScraplingMCPServer:
cookies=cookies,
cdp_url=cdp_url,
headless=headless,
+ block_ads=True,
max_pages=max_pages,
useragent=useragent,
timezone_id=timezone_id,
@@ -569,6 +570,7 @@ class ScraplingMCPServer:
cookies=cookies,
cdp_url=cdp_url,
headless=headless,
+ block_ads=True,
max_pages=len(urls),
useragent=useragent,
timezone_id=timezone_id,
@@ -777,6 +779,7 @@ class ScraplingMCPServer:
timeout=timeout,
cookies=cookies,
headless=headless,
+ block_ads=True,
useragent=useragent,
timezone_id=timezone_id,
real_chrome=real_chrome,