Creates a URL graph walker.
The generated task converts a feed of seed URLs into a feed of the URLs reachable from them, so that a consumer works on a whole graph of URLs while stating no more than the step from one URL to the next. URLs are emitted breadth-first in level order, every seed first, then every URL one step away from a seed, and so on, so that the first arrival at a URL is also its shallowest one.
Crawling navigates a graph of URLs without retrieving what they stand for: retrieving a URL belongs to the pipe
walker is built from and deriving results from the crawled URLs to the tasks downstream. Seeds and links are
stated as URLLike values, but reach walker and the feed as parsed objects, each one the crawl's own and
safe to be altered.
walker do; no URL reachable from a seed is emitted until the source runs
dry, so the feed never completes on an endless source.URLs are crawled at most once across the whole feed, whatever seed they are reached from, so cyclic and converging graphs are crawled without duplicates and without looping. They are matched by canonical form, so that an omitted path or an uppercase host is crawled once, while what the parser keeps apart, a trailing slash or a fragment among them, is crawled as a distinct URL.
A task converting a feed of seed URLs into a feed of the seeds and the URLs reachable from them, each as a parsed object
Creates a URL graph harvester.
The generated task converts a feed of seed URLs into a feed of results derived from what the crawled URLs stand for, so that a consumer harvests a whole graph of URLs while stating the retrieval of a URL as a pipe of its own. Each crawled URL is handed over once, whatever the number of links converging on it, and every value it is read as is both walked and mapped from that single reading, so that the crawl is driven and harvested without reading a URL twice. Results are emitted in the level order the URLs are crawled in, the results of every seed first, then those of every URL one step away from a seed, and so on.
Retrieval is stated as a task over a whole level rather than as a step per URL, so how many URLs are retrieved at a
time is the consumer's to state with the tasks already at hand: a forked feeder retrieves several at once, an
unforked one retrieves them in turn. A URL is left out of the harvest by emitting nothing for it. Seeds and links
are stated as URLLike values, but reach feeder as parsed objects, each one the crawl's own and safe to be
altered.
feeder draws them and those of the reachable URLs
level by level, so the feed produced runs dry as the feed drawn from, feeder, walker and mapper do; no
URL reachable from a seed is fed until the source runs dry, so the feed never completes on an endless source.URLs are crawled at most once across the whole feed, whatever seed they are reached from, and matched by canonical form, as for the single-step form.
feeder is applied to one level at a time, so state it initialises on invocation is scoped to that level rather
than to the crawl, and state spanning the crawl belongs to the enclosing closure. Levels are kept apart whatever
the task does, while order within a level is the task's own, so a feeder retrieving several URLs at a time
harvests a level in completion order.
The type of what a crawled URL stands for
The type of the results derived from a crawled URL
The task stating what the URLs of a level stand for, emitting nothing for a URL to be crawled no further and to contribute no result
The function stating the URLs linked from what a URL stands for, none if it is a leaf
The function stating the results derived from what a URL stands for, either a single result or a sequence of them, none if it contributes no result
A task converting a feed of seed URLs into a feed of the results derived from every crawled URL
Error While the feed is consumed, whatever the source reports while producing seeds, or
whatever feeder, walker and mapper report while reading, walking and mapping a URL
TypeError While the feed is consumed, if a seed or a link cannot be parsed on its own, a relative reference among them
await pipe(
(items(["https://example.com/products/"]))
(crawl(
fork(4, urls => urls(parse())), // the pages the URLs stand for, four retrievals at a time
page => page.links(".pagination a"), // the index pages it paginates to
page => page.links(".entry a") // the item links it lists
))
(toArray())
); // the item links of every index page
Creates a URL graph walker or harvester.