Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Repository files navigation

WebCrawler

A cross-platform (Windows, macOS, Linux) link checker. Give it a web address and it follows every link on the site, then shows each address with its status, HTTP code, content type, size and response time, so broken links, redirects and slow pages stand out.

Features

  • Follows links on pages of the starting site up to a configurable depth; links to other sites are listed but not followed.
  • Ignores the #fragment of an address (it is never sent to the server), so page#a and page#b are checked once, as page.
  • Static resources (off by default): with the Also check static resources setting (--resources on the command line) the images, scripts, stylesheets, icons and media a page loads are checked like its links. Pages at the depth limit are still read for their resources (their links are not followed). Files that a stylesheet or script loads in turn are not checked.
  • Reports errors (4xx/5xx, unreachable hosts, invalid addresses), redirects (with their target) and response times.
  • Several requests at once, but never more than a set number per second to one site (see Politeness below).
  • Quick scan: only sends HEAD requests (falling back to GET for servers that reject them). Fast, but pages are not read, so no links are followed.
  • Ignore list: addresses containing one of these texts are listed as skipped and never requested.
  • Highlight list: regular expressions matched against the page text; matching rows get your colour.
  • URL history: the URL box is a dropdown of the last 10 starting addresses you scanned (kept in the settings file).
  • Several measurements per address, to average out response times.
  • Saves a report as CSV (.csv), tab-separated text (any other extension) or prints it to the console.
  • Find: Ctrl+F (or the Find button) opens a small window that stays open while you search the list. Find Next selects the next row that contains all the words you typed (in the address, notes, content type, status or HTTP code), ignoring case, and starts again from the top after the last row. Find Prev (or Shift+Enter) does the same going up the list and starts again from the bottom after the first row.

Requirements

  • Windows 10 or later, a macOS version supported by .NET 10, or a desktop Linux (X11 or Wayland through XWayland) on x64 or arm64
  • To run a build: the .NET 10 Runtime (to build: the .NET 10 SDK)

The window is built with Avalonia UI, which draws it itself, so nothing else has to be installed on Windows and macOS.

Build and run

The commands are the same on every system; run them in the folder that holds WebCrawler.sln.

macOS (Terminal)

brew install --cask dotnet-sdk   # or install the .NET 10 SDK from https://dotnet.microsoft.com/download/dotnet/10.0
dotnet build WebCrawler.sln
dotnet run --project WebCrawler

Windows (PowerShell or Command Prompt; install the .NET 10 SDK first, for example with winget install Microsoft.DotNet.SDK.10)

dotnet build WebCrawler.sln
dotnet run --project WebCrawler

Linux (install the .NET 10 SDK with your package manager or from the Microsoft download page; a desktop session with libfontconfig and, for X11, libX11, libICE and libSM is needed, which any normal desktop has)

dotnet build WebCrawler.sln
dotnet run --project WebCrawler

Arguments for the program go after --: dotnet run --project WebCrawler -- -d 3 https://example.com/. You can also open WebCrawler.sln in Visual Studio, JetBrains Rider or VS Code (C# Dev Kit) and run the WebCrawler project.

To make a build that runs without the .NET runtime installed, publish it for the target system, for example:

dotnet publish WebCrawler -c Release -r osx-arm64 --self-contained -o publish/osx-arm64
dotnet publish WebCrawler -c Release -r win-x64 --self-contained -o publish/win-x64
dotnet publish WebCrawler -c Release -r linux-x64 --self-contained -o publish/linux-x64

(runtime identifiers: osx-arm64, osx-x64, win-x64, win-arm64, linux-x64, linux-arm64).

Run the tests (they start a small local web server, no internet needed):

dotnet test

Command line

WebCrawler [options] [url]
Option Meaning
url Address to start from; the scan begins at once.
-i <file> Read addresses from a text file, one per line. The first valid one defines which addresses count as part of the site.
-d <n> Maximum depth of link following (overrides the setting for this run).
-n <n> Number of measurements per address (overrides the setting for this run).
-o <file> Save the report when the scan is finished and close the program. %d in the name becomes today's date (yyyyMMdd). -o console prints the report to the console instead.

Example: WebCrawler -d 3 -o report-%d.csv https://example.com/

Command-line program (Linux, for CI/CD)

webcrawler is a separate program with no window and nothing but the .NET runtime inside it (the release has a single self-contained file for linux-x64 and linux-arm64, webcrawler-cli-<version>-linux-<arch>.tar.gz). It also builds and runs on Windows and macOS: dotnet run --project WebCrawler.Cli -- <options>.

webcrawler [options] [url]

The first line of the output is the program's name and version (WebCrawler 1.9.0). Without -o the results are printed to the console: a table of every address, then the summary of the scan (the same numbers as the Report button) and the list of errors with the page each was found on. Progress goes to the error output every few seconds (-q turns it off, and also leaves out the table). The program's settings file is not read: the defaults and the options below decide, so a scan behaves the same on every machine. Unlike the window program it defaults to depth 1, 10 connections and no delay between requests; use --delay to be gentler on a site.

Option Meaning
url Address to start from; it defines which addresses count as part of the site.
-i, --input <file> Read addresses from a text file, one per line. The list is checked with HEAD requests only (quick scan: no pages are read, no links followed, -d has no effect) unless --full is given.
--full With -i: request every page completely and follow its links, like a scan from a start address.
-d, --depth <n> Maximum depth of link following (default 1: the start page and the pages it links to).
-n, --measurements <n> Measurements per address (default 1).
-q Quick scan (HEAD requests only).
-t, --threads <n> Number of simultaneous requests (default 10).
--delay <ms> Least time between two requests to the same site (default 0 = none).
-r, --resources Also check static resources (images, scripts, stylesheets, icons, media). Off by default.
--user-agent <text> The User-Agent header.
--exclude <text> Skip addresses containing this text; can be repeated.
--cookie <NAME=VALUE> A cookie sent with every request; can be repeated.
-o, --output <file> Save the report to a file instead of printing it (CSV for .csv, otherwise tab-separated; %d = today's date). -o console prints it.
-s, --status <list> Only list addresses with these statuses (comma separated, repeatable): Done, Redirected, Warning, Error, External, Skipped. It filters the table or the report file; the summary and the error list still cover the whole scan.
--no-fail Exit with 0 even when there are errors.
-q, --quiet No progress lines and no table of addresses on the console: only the summary and the errors. A report file given with -o is still written.
--version, -h, --help Version, usage.

Exit codes: 0 no address ended in an error, 1 at least one did, 2 bad command line or unreadable/unwritable file, 130 the scan was interrupted (Ctrl+C or the termination signal of the CI job; what was found so far is still printed).

Example for a pipeline step that fails when the site has a broken link:

./webcrawler -o report.csv https://staging.example.com/

Settings

Settings are stored as JSON, in config.json next to the program if such a file exists (a portable copy keeps its own settings), otherwise in the user's settings folder:

System Location
Windows %AppData%\WebCrawler\config.json
macOS ~/Library/Application Support/WebCrawler/config.json
Linux $XDG_CONFIG_HOME/WebCrawler/config.json (default ~/.config/WebCrawler/config.json)
Setting Default Meaning
MaxProcesses 5 Number of simultaneous requests.
MaxDepth 5 How many links deep from the starting address pages are searched for further links.
MaxMeasurements 1 How many times each address is requested (the shown time is the average).
QuickScan false Use HEAD requests only.
CheckResources false Also check the static resources of each page: images (the src of img; a srcset only lists the same picture in other sizes, so it is not followed), scripts, stylesheets, icons, video/audio/source/track files and video posters. Set in the Settings window.
RequestDelayMs 100 Least time in milliseconds between two requests to the same site, however many connections are used (100 = at most 10 requests per second). 0 removes the limit.
UserAgent empty The User-Agent header to send. Empty means Mozilla/5.0 (compatible; Lindblad Automation WebCrawler/<version>).
Cookies empty Cookies sent with every request, one NAME=VALUE per line (a pasted a=1; b=2 works too). Set in the Settings window; stored as plain text in the config file.
RecentUrls none The last 10 starting addresses a scan was started from, newest first. They fill the dropdown of the URL box; the program keeps this list itself.
ExcludeRules none Texts; addresses containing one are skipped (case-sensitive).
HighlightRules none Expression (regular expression, case-insensitive) and HighlightColor (for example 0xff8000).

Settings saved by earlier versions (config.xml next to the program) are imported the first time the program starts. A config.json that cannot be read is renamed to config.json.bad and the defaults are used.

Politeness

  • Every request carries a User-Agent header (many sites refuse requests without one). Set UserAgent to use your own.
  • Requests to one site are spaced at least RequestDelayMs apart, whatever MaxProcesses is. More connections then mainly help when pages are slow to answer; lower the delay (or set it to 0) to scan a site of your own faster.
  • The site is the address you start from, and its subdomains: starting at https://expeditions.com also follows https://world.expeditions.com/page. The parent domain and sibling subdomains are only listed, not followed, and so is everything on another scheme or port. A start address with a path (https://expeditions.com/blog/) limits the scan to that path, on subdomains too.
  • A request that gets no answer within 20 seconds is reported as an error, so a hanging address does not hold up a connection for long.
  • robots.txt is not read: the program checks every address of the site you give it. Only use it on sites you may check.
  • TLS versions are left to the operating system, so TLS 1.3 works.

Project layout

Project Contents
WebCrawler The Avalonia application (Views/ holds the AXAML windows, ViewModels/ their MVVM view models, built with CommunityToolkit.Mvvm): main window with the results grid, Settings, Link Information and Find windows, report export.
WebCrawler.Cli The command-line program (CliOptions reads the arguments, CliRunner runs the scan and prints the results).
WebCrawler.Core The crawler, with no user interface: Crawler (asynchronous workers), URLCollection (the list of addresses and the work queue), Settings. Uses AngleSharp to read pages.
WebCrawler.Tests xUnit tests, including crawls of a scripted local web server (redirects, errors, encodings, stopping).

How a scan works: the workers (Crawler) take the next waiting address from the URLCollection, request it with HttpClient, read the page if it is text, and add every link found. A timer on the UI thread copies the results to the grid a few at a time (worker threads never touch the window), so a fast crawl never freezes it. Stopping cancels the requests in flight.

Continuous integration

.github/workflows/build.yml runs for every push to the main branch and every pull request. An ordinary build only builds and tests on Windows (a quick check that the code compiles and the tests pass) and produces no artifacts.

A release (see below) builds and tests on Windows and macOS and attaches the results to the GitHub release: WebCrawler-<version>-win.zip (needs the .NET 10 Runtime) and WebCrawler-<version>-macos-arm64.zip / WebCrawler-<version>-macos-x64.zip (a self-contained WebCrawler.app for Apple silicon and Intel Macs). The macOS builds therefore run only for releases, so a macOS-only problem shows up when you release.

To publish a release, push a tag named v and the version you want, on a commit that is already on the main branch:

git push
git tag v1.8.0
git push origin v1.8.0

The builds then also create a GitHub release with exactly that version. The release, named WebCrawler 1.8.0, is on the tag v1.8.0, has WebCrawler-1.8.0-win.zip, WebCrawler-1.8.0-macos-arm64.zip and WebCrawler-1.8.0-macos-x64.zip attached, and has release notes listing the commits since the previous release.

  • The tag must be v followed by three numbers (v1.8.0). Nothing chooses the version for you, so look at the latest release (or git tag --list 'v*') first and go up from it.
  • The build fails, and nothing is published, if the tag has any other form (v1.8, v1.8.0-beta) or if its commit is not on the main branch.
  • A wrong tag can be removed with git tag -d v1.8.0 and git push origin :refs/tags/v1.8.0; delete the release it created on GitHub as well.

The Windows zip needs the .NET 10 Runtime on the target machine. The macOS app is signed ad hoc only (there is no Apple developer account), so macOS blocks it the first time it is opened after a download: right-click WebCrawler.app, choose Open and confirm, or run xattr -dr com.apple.quarantine WebCrawler.app once.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages