pipolinkcheck

command module
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2026 License: Apache-2.0 Imports: 32 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

pipolinkcheck

CI Go Reference Release License codecov

A concurrent website crawler that finds and reports broken links. It follows a, img, link, script, video and source tags, then writes every broken link it finds to a CSV report, while throttling requests and parallelizing across multiple workers.

Works with any website — audit your site's links (see example.com).

Installation

Install the latest released version with go install:

go install github.com/jlettori/pipolinkcheck@latest

The binary is installed to $GOBIN, or to $GOPATH/bin when GOBIN is unset; make sure that directory is on your PATH.

To build from source instead (requires Go 1.26+):

git clone https://github.com/jlettori/pipolinkcheck.git
cd pipolinkcheck
make build

Antivirus false positives

Unsigned Go binaries are frequently flagged by antivirus software as suspicious, even when they are completely clean. This is a known false positive caused by heuristics matching statically-linked Go executables.

The most common detection is Microsoft Defender's Trojan:Win32/Wacatac.C!ml. The !ml suffix means it comes from a machine-learning heuristic, not a malware signature, and it is widely reported against freshly built Go binaries (especially when built with a very recent Go toolchain, before antivirus vendors update their models). It is a false positive: this repository only crawls and checks the links of websites.

If you get a Wacatac.C!ml detection, the fastest way to clear it is to report the file to Microsoft's security team as a false positive:

  1. Rebuild the binary from this source so you can attest it is yours.
  2. Submit it to https://www.microsoft.com/wdsi/filesubmission (sign in with a Microsoft account), selecting "My submission was incorrectly detected as malware" and noting the build revision.
  3. Also add an exclusion in Defender for your local build directory so the binary is usable while Microsoft processes the report.

To confirm the binary you build is safe, rebuild from this source and compare the SHA-256 hash — a reproducible build from the same revision always produces the same bytes.

Usage

pipolinkcheck [options]

Run pipolinkcheck -h to see the full list of options:

Usage: pipolinkcheck [options]

Version: dev

Options:
  -allowed string
    	Comma-separated list of allowed URL prefixes
  -base string
    	Base URL to start crawling from (default "https://example.com/")
  -chrome-profile string
    	Chrome user data directory for persistent cookies/login
  -excluded string
    	Comma-separated list of excluded URL prefixes
  -group-regex string
    	case-insensitive regex extracting the group value from the selector's text (first capture group, or the whole match)
  -group-selector string
    	CSS selector whose text supplies the group value for a page
  -headed
    	show Chrome window (use for manual SAML/login)
  -insecure-tls
    	skips TLS certificate verification (not recommended)
  -log-all
    	log every visited link in the CSV result, not only broken ones
  -login
    	open Chrome to the base URL for manual login, then exit
  -maxlinks int
    	Maximum number of unique links to crawl (0 for default) (default 1000000)
  -maxreqs int
    	Maximum requests per second (default 20)
  -no-external
    	skips checking links outside the allowed prefixes
  -output string
    	Output CSV file path
  -render-tabs int
    	Number of Chrome tabs used concurrently (0 for default 4) (default 4)
  -user-agent string
    	User-Agent header sent with every request (default "Mozilla/5.0 (compatible; PipoLinkCheckBot/1.0)")
  -verbose
    	detailed logging output for debugging and monitoring purposes (default true)
  -workers int
    	Number of parallel workers (0 for auto-compute based on CPUs)

Options

Flag Default Description
-base https://example.com/ URL to start crawling from
-allowed root URL Comma-separated URL prefixes the crawler is allowed to visit; root-relative entries (e.g. /docs) are resolved against -base
-excluded (none) Comma-separated URL prefixes to skip; root-relative entries (e.g. /admin) are resolved against -base
-maxreqs 20 Maximum requests per second (automatically clamped to 2–20)
-maxlinks 1000000 Maximum number of unique links to crawl before discovery stops (bounds memory usage)
-workers 0 Number of parallel workers (0 auto-computes from CPU count; clamped to 2–16)
-output derived from URL Output CSV file path (e.g. pipolinkcheck-www.example.com.csv)
-group-selector (none) CSS selector whose text supplies the group value of each page; discovered links inherit it
-group-regex (none) Case-insensitive regex extracting the group value from that text (first capture group, or the whole match); must be used with -group-selector
-user-agent Mozilla/5.0 (compatible; PipoLinkCheckBot/1.0) User-Agent header sent with each request
-verbose true Log every crawled URL; use -verbose=false to silence
-log-all false Write every visited link to the CSV result, not only broken ones; the summary CSV is unchanged
-insecure-tls false Skip TLS certificate verification (only for self-signed sites; not recommended)
-no-external false Skip checking links outside the allowed prefixes
-render-tabs 4 Number of Chrome tabs rendering pages concurrently (0 uses the default 4)
-chrome-profile auto-detected Chrome user data directory used to persist cookies/login
-headed false Show the Chrome window (use for manual SAML/login)
-login false Open Chrome at the base URL for manual login, then exit

Any option listed under Options may also be set programmatically via NewConfigWithOptions (see config.go) when embedding the crawler in your own Go program.

Examples

Basic crawl

Crawl a site staying within its own domain (the root host is allowed by default):

pipolinkcheck -base https://example.com
Explicitly restrict the crawl to matching prefixes

Only follow URLs beginning with https://example.com/:

pipolinkcheck -base https://example.com -allowed https://example.com

Allow a site and all its subdomains:

pipolinkcheck -base https://example.com \
  -allowed https://example.com,https://www.example.com,https://blog.example.com

Stray beyond the root host, e.g. also crawl a CDN that hosts images:

pipolinkcheck -base https://example.com \
  -allowed https://example.com,https://cdn.example.net

If -allowed is omitted, the root URL is allowed by default. When you pass -allowed, it replaces that default, so include the root host (and any other prefixes) explicitly if you want them crawled.

Use root-relative prefixes

Prefixes may be written relative to the root URL — a leading / is resolved against -base, so you don't have to repeat the full host:

pipolinkcheck -base https://example.com \
  -allowed /docs,/api \
  -excluded /admin,/tmp

This is equivalent to -allowed https://example.com/docs,https://example.com/api and -excluded https://example.com/admin,https://example.com/tmp. Absolute URLs work exactly as before.

Exclude parts of the site

Skip a section you know is heavy or has thousands of stale pages:

pipolinkcheck -base https://example.com -excluded https://example.com/archive,https://example.com/tmp

Allowed and excluded prefixes can be combined — excluded wins over allowed:

pipolinkcheck -base https://example.com \
  -allowed https://example.com,https://cdn.example.net \
  -excluded https://example.com/admin,https://cdn.example.net/private
Control crawling speed

Slow things down to be polite to the server / avoid rate limiting (clamped to a minimum of 2):

pipolinkcheck -base https://example.com -maxreqs 2

Speed up for a large site:

pipolinkcheck -base https://example.com -maxreqs 20

The value is automatically clamped to the 2–20 range, so out-of-range values are safe to pass.

To keep memory usage bounded, the crawler stops discovering new links once it has queued -maxlinks unique URLs (1000000 by default — enough for large enterprise sites):

pipolinkcheck -base https://example.com -maxlinks 50000

Lower the value to make a quick pass over a big site, or raise it for a full inventory.

Choose the output file
pipolinkcheck -base https://example.com -output /tmp/broken-links.csv

If -output is omitted, a filename is derived from the URL (pipolinkcheck-www.example.com.csv) and the crawler also writes a matching summary CSV (pipolinkcheck-www.example.com.summary.csv). No .log file is produced.

Use a custom User-Agent
pipolinkcheck -base https://example.com \
  -user-agent "Acme-SiteAudit/2.5 (+https://acme.example)"
Silence verbose per-URL logging
pipolinkcheck -base https://example.com -verbose=false

By default the CSV report contains only broken links. Add -log-all to write every visited link to the CSV as well, with its HTTP status code. The CSV is streamed continuously; the summary CSV is not modified by -log-all.

pipolinkcheck -base https://example.com -log-all
Crawl a site with a self-signed certificate
pipolinkcheck -base https://intranet.local -insecure-tls

Security note: only use -insecure-tls for internal sites with self-signed / non-trusted certificates. Do not use it on public sites.

Crawl JavaScript-generated or authenticated pages

Every page is rendered with Chrome before links are extracted, so pages whose links are generated by JavaScript work out of the box. For intranet sites behind SAML/SSO, complete the login interactively first:

pipolinkcheck -base https://intranet.example -login

Chrome opens with a persistent profile (auto-detected, or set with -chrome-profile). After logging in, press Enter to close it, then run the crawl:

pipolinkcheck -base https://intranet.example

The login is reused on later runs: session cookies (the kind SAML/SSO providers usually issue) are rewritten with an expiry and Chrome is closed gracefully, so cookies, localStorage and IndexedDB are flushed to the profile. Note that sessionStorage is per-tab and in-memory, so it is not carried across separate runs.

Add -headed to watch the crawl in a visible Chrome window. In headed mode the tool opens the base URL and waits for a SAML/SSO login to complete. It detects the end of the flow automatically: as soon as Chrome lands back on an allowed URL (and the page has finished loading), the crawl starts without any further input. Press Enter to start the crawl immediately if detection cannot complete (for example when the post-login page is outside the allowed prefixes). Rendering is slower than a plain HTTP fetch because each page waits for JavaScript to settle.

Pages are rendered in several tabs at once: -render-tabs controls how many (default 4, up to 16). Raise it to speed up rendering at the cost of more CPU and memory:

pipolinkcheck -base https://intranet.example -render-tabs 8

All tabs open in the same Chrome window and share the same browser profile and login session.

Group results by a value on each page

On sites that host several tenants, brands or sections in one crawl, you can tag every row with a value taken from the page where the link was found:

pipolinkcheck \
  -base https://intranet.example \
  -group-selector '#client' \
  -group-regex 'Client (\w+)'

For each page, the crawler reads the text of the first element matching the CSS selector (after JavaScript has settled) and applies the regex. The first capture group is used — Client ACME above yields ACME. If the regex has no capture group, the whole match is used. Matching is case-insensitive, but the captured value keeps its original case. Missing elements, non-matching regexes and empty captures all produce an empty Group value; the row is still written. Links discovered on a page inherit that page's group, and -log-all rows are grouped too.

Both flags must be supplied together. The group value appears in the CSV's Group column and in the summary CSV — no files are split.

A full example combining options
pipolinkcheck \
  -base https://www.example.com \
  -allowed https://www.example.com,https://static.example.com \
  -excluded https://www.example.com/account,https://www.example.com/api \
  -maxreqs 8 \
  -user-agent "Acme-SiteAudit/2.5" \
  -output /tmp/example-report.csv \
  -verbose=false

Output

The crawler produces two files:

1. CSV report (-output path, .csv by default)

A semicolon-delimited (;) CSV with the following columns:

Column Description
MIME Type Response Content-Type (e.g. text/html, image/png), or unknown when no response was received
Source Page The page the broken link was discovered on
Link Name Visible link text (hyperlinks) / alt or title attribute
Selector A CSS-like path locating the element on the page (e.g. main#contents > section.block > p > a). Everything before <body> is omitted; class lists are capped at three classes per element; the full element depth is preserved
Link The URL that was checked (broken, or every visited link with -log-all)
Status Code HTTP status returned (e.g. 404), or one of the internal codes below when the link fails before an HTTP response
Error message Human-readable description of the failure — the standard status description for HTTP errors (e.g. Not Found), or the textual error for internal failures (e.g. DNS, TLS, timeout)
Group Value extracted from the source page with -group-selector/-group-regex; empty when no grouping is configured or the page does not match

Internal error codes written to the Status Code column when a request fails before any HTTP response is received:

Code Meaning
1002 The request could not be completed in Chrome (navigation/TLS/DNS error)
1003 Processing the link panicked

Example report:

MIME Type;Source Page;Link Name;Selector;Link;Status Code;Error message;Group
text/html;https://www.example.com/;;main#contents > section.block > p > a;https://www.example.com/old-page.html;404;Not Found;ACME
image/png;https://www.example.com/;banner;header > div.logo > img;https://www.example.com/img/banner.png;500;Internal Server Error;ACME
text/html;https://www.example.com/contact;read more;footer > ul.footer-links > li > a;https://www.example.com/privacy;404;Not Found;

The file is written with a UTF-8 BOM so it opens correctly in Excel/LibreOffice. Cells are escaped to prevent spreadsheet formula injection.

2. Summary CSV (<output>.summary.csv)

A semicolon-delimited summary with the header Group;Section;Key;Count. Each group (empty when grouping is not configured) gets rows for links enqueued, visited resources by MIME type, errors by MIME type, errors by status code and total errors. -log-all does not modify this file. No human-readable .log file is written.

Group;Section;Key;Count
;Links enqueued;;12
;Visited resources;text/html;10
;Total errors;;0
ACME;Links enqueued;;3
ACME;Visited resources;text/html;3
ACME;Errors by status code;404;1
ACME;Total errors;;1

Development

make test      # run tests with coverage profile
make race      # run tests with the race detector enabled
make fmt       # format code (requires gofumpt)
make coverage  # generate coverage report
make build     # build binary
make clean     # remove build artifacts

The project includes unit tests for the crawler, config, result writer, stats, HTTP layer, HTML parsing, and verification helpers. CI runs the test suite (with coverage uploaded to Codecov) and the race detector on Linux, and builds binaries for Linux and Windows. Release builds additionally publish a macOS binary via GoReleaser.

Documentation

Overview

Package main implements pipolinkcheck, a command-line link checker that crawls a site, validates its hyperlinks and assets, and reports broken links to a CSV file.

Jump to

Keyboard shortcuts

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