Web Crawler
A focused demo of WebSpark.HttpClientUtility.Crawler โ the companion NuGet package
that adds site crawling to the base HTTP utility.
Run a Crawl
Package Setup
Install both packages:
dotnet add package WebSpark.HttpClientUtility
dotnet add package WebSpark.HttpClientUtility.Crawler
Register in Program.cs:
services.AddHttpClientUtility();
services.AddHttpClientCrawler();
Crawler Features
-
robots.txt compliance
Reads and respects
Disallowrules before crawling any path -
Sitemap & RSS discovery
Auto-seeds the queue from
sitemap.xml,rss.xml,atom.xml -
HTML link extraction
Parses
<a href>tags via HtmlAgilityPack, same-domain only -
Depth-limited crawling
BFS with configurable
MaxDepthandMaxPagesguards -
Adaptive rate limiting
Adjusts delays based on server response times to avoid overloading hosts
-
Concurrent requests
Configurable
MaxConcurrentRequestsfor throughput control
Usage Example
var result = await crawler.CrawlAsync(
"https://markhazleton.com",
new CrawlerOptions {
MaxPages = 20,
MaxDepth = 2,
RespectRobotsTxt = true,
DiscoverFromSitemapAndRss = true,
RequestDelayMs = 300
});