Skip to content
zooskyPublic

About

"The Swiss Army knife for website quality."

Resources

Contributing

Stars

1 star

Watchers

1 watching

Forks

Repository files navigation

Web Diff

CI crates.io docs.rs downloads rust-version license

Web Diff (webdiff) is a tool for website migration and redesign verification. It crawls an old site and a new site, and finds what the change broke:

  • the pages of the old site that the new site does not have, and the new pages,
  • the differences of the SEO metadata and of the text of each page,
  • the broken links and assets of the new site,
  • the old URLs that do not redirect to their new page,
  • the pages that look different from an earlier screenshot, or from an other page (since version 0.3.0).

The command line program is webdiff. The library is the crate webdiff.

Install

With Homebrew, on macOS and Linux:

brew install zoosky/tap/webdiff

Each GitHub release has the binaries for macOS (ARM and Intel) and Linux (x86_64 and ARM). Each binary has a checksum. The Linux binaries for glibc need glibc 2.34 or newer. Since 0.3.0, the releases also have static Linux binaries (musl) for x86_64 and ARM, which need no glibc. Homebrew on Linux installs the glibc binary.

A shell installer selects the binary. It takes the glibc binary on glibc 2.35 or newer, else the static binary:

curl --proto '=https' --tlsv1.2 -LsSf https://github.com/zoosky/webdiff/releases/latest/download/webdiff_cli-installer.sh | sh

With Cargo, from crates.io, with Rust 1.100.1 or newer. The build needs a C compiler, for example the package build-essential of Debian and Ubuntu. On Linux, version 0.2.0 also needs the headers of OpenSSL and pkg-config (the packages libssl-dev and pkg-config). Version 0.3.0 and later need no OpenSSL:

cargo install --locked webdiff_cli

Quick start

  1. Install webdiff, as above.

  2. Compare an old site with a new site. Give the start URL of each site:

    webdiff site https://www.old.example/ https://www.new.example/
  3. Read the result. The first line names the two crawls. The next lines name the problems, at most 20 of each kind, and a line with the counts ends the summary. The exit status is 1 when a page of the old site is missing on the new site. So the command can stop a CI job. For a report that you can send to other persons, write the HTML report:

    webdiff site https://www.old.example/ https://www.new.example/ --format html --output report.html

When the new site has other URLs for the same pages, give a mapping rule, as in the next section. Crawl only sites that you own or have permission to test.

Compare the pages of an old site and a new site

webdiff site crawls two sites at the same time. For each page of the old site, it finds the URL of that page on the new site. Then it prints the missing pages, the new pages, the differences of the SEO metadata and of the text of each page, and the broken links and assets of the new site:

$ webdiff site https://www.old.example/ https://www.new.example/ --map /de/produkte/=/de/products/
Compared 9 pages of https://www.old.example/ with 9 pages of https://www.new.example/.
missing  https://www.old.example/team.html -> https://www.new.example/team.html (not found in the crawl)
new      https://www.new.example/blog/
seo      https://www.old.example/about.html -> https://www.new.example/about.html: title changed from "About us" to "About Example Shop"
content  https://www.old.example/about.html -> https://www.new.example/about.html: the text changed, score 0.81 (1 removed line)
links    broken asset https://www.new.example/missing.js (HTTP 404) on https://www.new.example/about.html
Matched: 8. Missing: 1. New: 1. SEO: 1. Content: 1. Links: 1.

A missing page gives exit status 1, so a CI job fails. --format json writes the full report, and --format html writes it as one HTML page for a browser. --content-diff diff.html writes an HTML page that marks the changed words of each page. See cli/README.md for the mapping rules, the JSON report, and the options. Crawl only sites that you own or have permission to test.

Check the redirects of the old URLs

webdiff redirects sends the path of each old URL to a host, follows the redirect chain, and checks that it ends at the new page with a permanent redirect. The old URLs come from a sitemap, a crawl, a snapshot, or a text file. See cli/README.md.

Write a load test plan

webdiff plan crawls the new site and writes a load test plan for driller: one request for each page, with no secret in the plan. See cli/README.md.

Save a site as a snapshot

webdiff snapshot saves the crawl of a site into a directory. webdiff site snapshot:DIR https://www.new.example/ then compares the new site with it, for example after the cutover, when the old site is gone. See cli/README.md.

Check the look of the pages

The visual check comes with version 0.3.0. Version 0.2.0 does not have it. The comparison of two live sites and the screenshots section of the project file come with version 0.4.0.

webdiff snapshot --screenshots also saves a full-page screenshot of each HTML page, in headless Chrome, at the widths of a phone, a tablet, and a desktop. It takes at most 100 pages by default (--screenshot-limit). Later, webdiff site snapshot:DIR NEW --screenshots takes the screenshots again, and finds the pages that look different. webdiff site OLD NEW --screenshots compares two live sites, for example a staging site against the production site. Chrome or Chromium must be installed. See cli/README.md.

Compare two pages

webdiff page <OLD> <NEW> fetches two single pages, with no crawl, and compares their status, their redirect, their SEO metadata, and their text. With --screenshots, it also compares their look in headless Chrome. See cli/README.md.

List the pages of a site

webdiff crawl <URL> crawls a site and prints the URLs of its pages, one on each line. See cli/README.md.

Describe a check in a project file

webdiff init writes webdiff.yml, a YAML file with the sites, the mapping rules, the crawl settings, and the thresholds of a migration check. Then webdiff site and webdiff redirects read it, so a team can commit the check and run it the same way each time. See cli/README.md.

Use the library

The crate webdiff has the crawl, the comparisons, and the reports of the command line program, for a program of your own. See webdiff/README.md.

Contribute

See CONTRIBUTING.md.

How to run the examples

cargo run --example site https://www.old.example/ https://www.new.example/ /de/produkte/=/de/products/

About

"The Swiss Army knife for website quality."

Resources

Contributing

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages