Docs/API reference

Sitemap · Python

Discover URLs from a sitemap or use them to seed a bounded crawl.

Download .md
Developers4 min read16 sections
Source reference · Match your SDK version. Availability and known issues
In this guide

Purpose and lifecycle

listUrls/list_urls returns an in-memory list of sitemap entries. It does not fetch each listed page.

maxDepth/max_depth limits sitemap-index recursion. depth limits subsequent crawling from each seed; these limits have different meanings.

For a large dataset, persist discovered URLs to a file and use DatasetJob. Inspect gzip and child-sitemap handling for your binding before relying on compressed sitemap support.

Definition and availability

Source snapshot: 1.0.0-alpha.3. Package export. Declared in source; this is not a runtime test result.

Signatures and source locations are generated from the SDK wrappers. Clean snapshots link to the recorded commit. Modified snapshots link to main, which may differ; file hashes identify the local inputs.

class Sitemap
python1 lines · copy-ready

Usage example

Use a matching source build. Where a snippet uses page, obtain it with the Page example first. Example URLs illustrate API shape; they are not promised datasets.

from crawlingo import Sitemap
entries = Sitemap("https://example.com/sitemap.xml").max_depth(3).list_urls()
with open("urls.txt", "w", encoding="utf-8") as out:
    for entry in entries:
        out.write(entry.loc + "\n")
python5 lines · copy-ready

Members

MemberKindReturn / value typeSource status
__init__methodNot annotated; see behavior notesPresent in source
max_depthmethod'Sitemap'Present in source
followmethod'Sitemap'Present in source
limitmethod'Sitemap'Present in source
depthmethod'Sitemap'Present in source
concurrencymethod'Sitemap'Present in source
delaymethod'Sitemap'Present in source
fieldmethod'Sitemap'Present in source
webhookmethod'Sitemap'Present in source
list_urlsmethodList[SitemapEntry]Present in source
buildmethodCrawlResultsPresent in source

__init__()

Create a sitemap discovery builder. Fetching begins with listUrls/list_urls or build; the constructor does not materialize discovered URLs.

Returns / value: Not annotated; see behavior notes.

def __init__(self, sitemap_url: str, *, session: Optional[Session]=None)
python1 lines · copy-ready
ParameterTypeRequired / defaultMeaning
sitemap_urlstrRequiredURL of a sitemap XML document or index.
sessionOptional[Session]Default: NoneShared request state. Omit only where the signature provides a default.

max_depth()

Maximum sitemap-index nesting depth.

Returns / value: 'Sitemap'.

def max_depth(self, depth: int) -> 'Sitemap'
python1 lines · copy-ready
ParameterTypeRequired / defaultMeaning
depthintRequiredNesting or crawl-hop limit, as specified by this method.

follow()

Configure links followed after a seed page is fetched.

Returns / value: 'Sitemap'.

def follow(self, selector: str) -> 'Sitemap'
python1 lines · copy-ready
ParameterTypeRequired / defaultMeaning
selectorstrRequiredSelector evaluated against the fetched DOM.

limit()

Configure the downstream crawl page limit.

Returns / value: 'Sitemap'.

def limit(self, pages: int) -> 'Sitemap'
python1 lines · copy-ready
ParameterTypeRequired / defaultMeaning
pagesintRequiredMaximum downstream crawl pages.

depth()

Configure the downstream crawl hop limit.

Returns / value: 'Sitemap'.

def depth(self, max_depth: int) -> 'Sitemap'
python1 lines · copy-ready
ParameterTypeRequired / defaultMeaning
max_depthintRequiredMaximum sitemap nesting or crawl depth, according to the API.

concurrency()

Configure concurrent downstream crawl workers.

Returns / value: 'Sitemap'.

def concurrency(self, n: int) -> 'Sitemap'
python1 lines · copy-ready
ParameterTypeRequired / defaultMeaning
nintRequiredCount or index; see the method description.

delay()

Configure downstream crawl delay in seconds.

Returns / value: 'Sitemap'.

def delay(self, seconds: float) -> 'Sitemap'
python1 lines · copy-ready
ParameterTypeRequired / defaultMeaning
secondsfloatRequiredTime in seconds; see the method-specific range and timing semantics.

field()

Add a downstream extraction field.

Returns / value: 'Sitemap'.

def field(self, name: str, selector: str, selector_type: str='css', default: Optional[str]=None) -> 'Sitemap'
python1 lines · copy-ready
ParameterTypeRequired / defaultMeaning
namestrRequiredField, header or attribute name for this operation.
selectorstrRequiredSelector evaluated against the fetched DOM.
selector_typestrDefault: 'css'Selector engine for this field; supported values differ between builders.
defaultOptional[str]Default: NoneFallback field value when extraction is empty.

webhook()

Set a downstream result endpoint; delivery is not durable.

Returns / value: 'Sitemap'.

def webhook(self, url: str) -> 'Sitemap'
python1 lines · copy-ready
ParameterTypeRequired / defaultMeaning
urlstrRequiredHTTP(S) source URL; verify the target is appropriate for your application.

list_urls()

Fetch sitemap documents and return discovered URL entries; results are collected in memory.

Returns / value: List[SitemapEntry].

def list_urls(self) -> List[SitemapEntry]
python1 lines · copy-ready

build()

Seed a crawl with sitemap URLs and return its in-memory results.

Returns / value: CrawlResults.

def build(self) -> CrawlResults
python1 lines · copy-ready

Errors and operational limits

Node listUrls now propagates fetch/parse errors. Python list_urls can skip failing sitemap fetches in its native binding. Empty results can therefore have different meanings.

Source availability, package publication and runtime validation are separate facts. These pages describe the source snapshot, not a claim that all platforms or every API path have passed production acceptance.