Skip to content

Commit ba3478c

Browse files
author
stlc-bot
committed
feat(sitemap): add subdomain discovery
Stainless-Generated-From: 583748d
1 parent 6abaeba commit ba3478c

3 files changed

Lines changed: 30 additions & 10 deletions

File tree

‎src/context/dev/resources/web.py‎

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2207,6 +2207,7 @@ def web_scrape_sitemap(
22072207
*,
22082208
domain: str,
22092209
headers: Dict[str, str] | Omit = omit,
2210+
include_subdomains: bool | Omit = omit,
22102211
max_links: int | Omit = omit,
22112212
search: str | Omit = omit,
22122213
sitemap_url: str | Omit = omit,
@@ -2223,11 +2224,12 @@ def web_scrape_sitemap(
22232224
) -> WebWebScrapeSitemapResponse:
22242225
"""Crawl an entire website's sitemap and return all discovered page URLs.
22252226
2226-
Pass
2227-
`search` to have the crawled sitemap filtered down to the pages about a phrase
2228-
(for example `pricing and plans` or `api authentication docs`), most relevant
2229-
first — a searched crawl scans the whole sitemap and costs 2 credits instead
2230-
of 1.
2227+
Set
2228+
`includeSubdomains=true` to also discover public pages and sitemaps on child
2229+
hosts such as `docs.example.com` or `brand.example.com`. Pass `search` to have
2230+
the discovered URLs filtered down to the pages about a phrase (for example
2231+
`pricing and plans` or `api authentication docs`), most relevant first — a
2232+
searched crawl scans the whole sitemap and costs 2 credits instead of 1.
22312233
22322234
Args:
22332235
domain: Domain to build a sitemap for
@@ -2236,6 +2238,9 @@ def web_scrape_sitemap(
22362238
deep-object query params such as headers[X-Custom]=value. When provided, caching
22372239
is bypassed: the result is neither read from nor written to cache.
22382240
2241+
include_subdomains: When true, discover and include public pages and sitemaps on subdomains of the
2242+
requested domain. Defaults to false.
2243+
22392244
max_links: Maximum number of links to return from the sitemap crawl. Defaults to 10,000.
22402245
Minimum is 1, maximum is 100,000.
22412246
@@ -2281,6 +2286,7 @@ def web_scrape_sitemap(
22812286
{
22822287
"domain": domain,
22832288
"headers": headers,
2289+
"include_subdomains": include_subdomains,
22842290
"max_links": max_links,
22852291
"search": search,
22862292
"sitemap_url": sitemap_url,
@@ -4457,6 +4463,7 @@ async def web_scrape_sitemap(
44574463
*,
44584464
domain: str,
44594465
headers: Dict[str, str] | Omit = omit,
4466+
include_subdomains: bool | Omit = omit,
44604467
max_links: int | Omit = omit,
44614468
search: str | Omit = omit,
44624469
sitemap_url: str | Omit = omit,
@@ -4473,11 +4480,12 @@ async def web_scrape_sitemap(
44734480
) -> WebWebScrapeSitemapResponse:
44744481
"""Crawl an entire website's sitemap and return all discovered page URLs.
44754482
4476-
Pass
4477-
`search` to have the crawled sitemap filtered down to the pages about a phrase
4478-
(for example `pricing and plans` or `api authentication docs`), most relevant
4479-
first — a searched crawl scans the whole sitemap and costs 2 credits instead
4480-
of 1.
4483+
Set
4484+
`includeSubdomains=true` to also discover public pages and sitemaps on child
4485+
hosts such as `docs.example.com` or `brand.example.com`. Pass `search` to have
4486+
the discovered URLs filtered down to the pages about a phrase (for example
4487+
`pricing and plans` or `api authentication docs`), most relevant first — a
4488+
searched crawl scans the whole sitemap and costs 2 credits instead of 1.
44814489
44824490
Args:
44834491
domain: Domain to build a sitemap for
@@ -4486,6 +4494,9 @@ async def web_scrape_sitemap(
44864494
deep-object query params such as headers[X-Custom]=value. When provided, caching
44874495
is bypassed: the result is neither read from nor written to cache.
44884496
4497+
include_subdomains: When true, discover and include public pages and sitemaps on subdomains of the
4498+
requested domain. Defaults to false.
4499+
44894500
max_links: Maximum number of links to return from the sitemap crawl. Defaults to 10,000.
44904501
Minimum is 1, maximum is 100,000.
44914502
@@ -4531,6 +4542,7 @@ async def web_scrape_sitemap(
45314542
{
45324543
"domain": domain,
45334544
"headers": headers,
4545+
"include_subdomains": include_subdomains,
45344546
"max_links": max_links,
45354547
"search": search,
45364548
"sitemap_url": sitemap_url,

‎src/context/dev/types/web_web_scrape_sitemap_params.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ class WebWebScrapeSitemapParams(TypedDict, total=False):
2222
is bypassed: the result is neither read from nor written to cache.
2323
"""
2424

25+
include_subdomains: Annotated[bool, PropertyInfo(alias="includeSubdomains")]
26+
"""
27+
When true, discover and include public pages and sitemaps on subdomains of the
28+
requested domain. Defaults to false.
29+
"""
30+
2531
max_links: Annotated[int, PropertyInfo(alias="maxLinks")]
2632
"""Maximum number of links to return from the sitemap crawl.
2733

‎tests/api_resources/test_web.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,7 @@ def test_method_web_scrape_sitemap_with_all_params(self, client: ContextDev) ->
640640
web = client.web.web_scrape_sitemap(
641641
domain="xxx",
642642
headers={"foo": "J!"},
643+
include_subdomains=True,
643644
max_links=1,
644645
search="help center and troubleshooting articles",
645646
sitemap_url="https://example.com",
@@ -1293,6 +1294,7 @@ async def test_method_web_scrape_sitemap_with_all_params(self, async_client: Asy
12931294
web = await async_client.web.web_scrape_sitemap(
12941295
domain="xxx",
12951296
headers={"foo": "J!"},
1297+
include_subdomains=True,
12961298
max_links=1,
12971299
search="help center and troubleshooting articles",
12981300
sitemap_url="https://example.com",

0 commit comments

Comments
 (0)