sitemap

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 14, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package sitemap enumerates Douban's crawlable URL space from its sitemap backbone. There is exactly one backbone for the whole site (www.douban.com/sitemap_index.xml); every subdomain's robots.txt points at it. The index lists 10,706 gzipped child sitemaps of 50,000 URLs each, partitioned into contiguous bands by entity type, plus a daily updated index for freshness.

Index

Constants

View Source
const (
	IndexURL        = "https://www.douban.com/sitemap_index.xml"
	UpdatedIndexURL = "https://www.douban.com/sitemap_updated_index.xml"
)

The site-wide sitemap entry points.

Variables

View Source
var Bands = []Band{
	{"subject", 0, 88},
	{"review", 88, 285},
	{"group-topic", 285, 4890},
	{"event", 4890, 4925},
	{"people", 4925, 9995},
	{"note", 9995, 10635},
	{"celebrity", 10640, 10704},
	{"musician", 10705, 10706},
}

Bands is the approximate entity partition of the full index (probed 2026-06-14).

Functions

func Children

func Children(ctx context.Context, f Fetcher, childURL string) ([]string, error)

Children fetches a child sitemap, decompresses it, and returns its loc URLs.

func Gunzip

func Gunzip(data []byte) ([]byte, error)

Gunzip decompresses gzip data, passing already-plain XML through unchanged so callers need not know whether a child arrived compressed.

func Index

func Index(ctx context.Context, f Fetcher, indexURL string) ([]string, error)

Index fetches and parses the child loc list from an index URL.

func ParseIndex

func ParseIndex(data []byte) ([]string, error)

ParseIndex parses a sitemap index document into its ordered child loc URLs.

func ParseURLSet

func ParseURLSet(data []byte) ([]string, error)

ParseURLSet parses a (decompressed) child sitemap into its loc URLs.

func SelectBand

func SelectBand(children []string, name string) []string

SelectBand returns the children of the named band from an ordered index list, clamped to the list bounds. An unknown band name returns nil.

Types

type Band

type Band struct {
	Name  string
	Start int
	End   int
}

Band names a contiguous run of child sitemaps holding one entity type. The range is [Start, End) over the ordered child list. Boundaries drift as the catalog grows, so a crawl should sniff edge files before trusting them.

func BandByName

func BandByName(name string) (Band, bool)

BandByName returns the named band, or ok=false if unknown.

type Fetcher

type Fetcher interface {
	Get(ctx context.Context, url string) ([]byte, error)
}

Fetcher retrieves a URL's bytes. *douban.Client and *douban.FrodoClient both satisfy a compatible shape; the crawl layer adapts whichever it uses.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL