Skip to content

Official Crawl4AI Cloud: a hosted web scraping, extraction, and search API for AI agents. Free API key, 1,000 credits a month, no card. Fully open source: this repo is the Apache-2.0 crawler that powers it, and you can self-host it.

feat: add include_subdomains flag to DomainMapperConfig

unclecodeed60c6628a3a
diff --git a/crawl4ai/async_configs.py b/crawl4ai/async_configs.py
index 1037ebc4..40deea8e 100644
--- a/crawl4ai/async_configs.py
+++ b/crawl4ai/async_configs.py
@@ -2236,6 +2236,7 @@ class DomainMapperConfig:
scoring_method: str = "bm25",
probe_paths: Optional[List[str]] = None,
common_subdomains: Optional[List[str]] = None,
+ include_subdomains: bool = True,
use_browser_for_homepage: bool = False,
verbose: Optional[bool] = None,
cache_ttl_hours: int = 24,
@@ -2259,6 +2260,9 @@ class DomainMapperConfig:
scoring_method: Scoring algorithm. Currently only "bm25".
probe_paths: Extra paths to probe on each host (added to defaults).
common_subdomains: Extra subdomain prefixes to guess (added to defaults).
+ include_subdomains: Discover and scan subdomains. When False, only scans
+ the exact domain provided (skips crt.sh, DNS guessing,
+ Wayback/CC host discovery). Default True.
use_browser_for_homepage: Use Playwright for JS-rendered homepages.
verbose: Override logger verbose setting.
cache_ttl_hours: Hours before cached results expire.
@@ -2279,6 +2283,7 @@ class DomainMapperConfig:
self.scoring_method = scoring_method
self.probe_paths = probe_paths
self.common_subdomains = common_subdomains
+ self.include_subdomains = include_subdomains
self.use_browser_for_homepage = use_browser_for_homepage
self.verbose = verbose
self.cache_ttl_hours = cache_ttl_hours
diff --git a/crawl4ai/domain_mapper.py b/crawl4ai/domain_mapper.py
index 6e3fc0a0..d4ddf3c0 100644
--- a/crawl4ai/domain_mapper.py
+++ b/crawl4ai/domain_mapper.py
@@ -308,6 +308,14 @@ class DomainMapper:
"""Discover all subdomains/hosts under base_domain."""
hosts: Set[str] = {base_domain}
+ # When include_subdomains is False, skip all subdomain discovery
+ # and only scan the exact domain provided
+ if not getattr(config, "include_subdomains", True):
+ self._log("info", "Subdomain discovery disabled, scanning only {domain}",
+ params={"domain": base_domain})
+ validated = await self._validate_hosts(hosts, config)
+ return validated
+
discovery_tasks = []
if "crt" in sources: