Sitemap Product Matcher

← All AI-created software

This is AI-generated (aka vibe-coded) software. It is specific to my needs and my system and may not work for you or yours. Support is limited, but if you report a bug I'll certainly look into it. The code is provided in the zip file for you to review should you choose.
⬇️ Download Sitemap Product Matcher.zip27.4 KBLast Updated: November 14, 2026Python

Finds the page for each of your products on one or more web shops: it reads each site’s sitemaps, guesses a product name from every page URL, and fuzzy-matches your product list against those names.

On this page

Features

  • Finds every site’s sitemaps from robots.txt or the usual paths, following sitemap indexes and gzipped sitemaps
  • Fuzzy-matches product names against URL names, tolerant of word order, accents, typos and extra words
  • Flags ambiguous matches and, on request, shows the best near miss for products with no match
  • Checks matched pages on request, reading the product name, SKU, brand and price from JSON-LD, OpenGraph or the title
  • Stores every URL and match in a SQLite database, so you can match a new product list without retrieving again
  • Keeps an HTTP cache between runs, asking servers only whether a sitemap has changed
  • Filters URLs by regular expression or by text, when reading sitemaps and when matching

Usage

pip install curl_cffi
python sitemap-product-matcher.py --urls-file-path shops.txt --products-file-path tools.txt

It needs Python 3.8 or later. curl_cffi retrieves sitemaps and pages the way Chrome does, which sites with bot checks let through; without it, only --sitemap-mode stored works.

Input files

Two plain text files (UTF-8), one entry per line; blank lines and lines starting with # are skipped:

  • The URL file lists sites: https://shop.example.com, or just shop.example.com (https is assumed).
  • The product file lists product names as you write them: Acme cordless drill 18V.

A sample run

python sitemap-product-matcher.py --urls-file-path shops.txt --products-file-path tools.txt --exclude-url-text /blog/ --show-misses TRUE --verify-pages TRUE

prints the matches on stdout:

==============================================================================
http://shop.example
==============================================================================
  2 of 3 products matched against 3 URLs in 0.00s

  [1.00 @tier 0.99] Acme cordless drill 18V
        URL : http://shop.example/products/acme-cordless-drill-18v.html
        NAME: acme cordless drill 18v
        PAGE: Acme Cordless Drill 18V  [sku AD18]
              verified 1.00 via json-ld
  [0.90 @tier 0.87] Bolt circular saw
        URL : http://shop.example/products/bolt-circular-saw-7-1-4.html
        NAME: bolt circular saw 7 1 4
        PAGE: Bolt 7-1/4 in. Circular Saw
              verified 0.90 via meta:og:title
  [ --  ] Zeta laser level
        BEST: 0.37 (below --minimum-score)  acme impact driver 20v
              http://shop.example/products/acme-impact-driver-20v.html

------------------------------------------------------------------------------
Sites: 1 | URLs stored: 3 | Products: 3 | Matches: 2 | Ambiguous: 0

Each match shows its score from 0 to 1, the strictest score tier it reached, the page and the name read from its URL. AMBIGUOUS marks a match whose runner-up scores within --ambiguity-margin of it. With --verify-pages TRUE, PAGE is the name found on the page, with <-- page disagrees with the URL when it scores below --verify-warning-score.

Messages about the run (the folder, the database, how many URLs each site gave, request counts) go to stderr, so > matches.txt keeps only the matches.

The database and the cache

Both go in the working folder, beside the script unless --working-folder-path says otherwise:

  • <urls>_<products>.db (here shops_tools.db) holds every URL with its guessed name (sitemap_urls), each sitemap read (sitemap_docs), the products and the matches, with the runner-up and the page check (matches). Open it in any SQLite browser.
  • <urls>_<products>.cache.db keeps the sitemaps between runs. A second run sends conditional requests, so an unchanged sitemap costs a 304 response instead of a download.

Matching again without retrieving

--sitemap-mode stored retrieves nothing and matches against the URLs already in the database: use it to try another product list, other filters or another --minimum-score. Given another product file, it uses the newest database for the same URL file.
--sitemap-mode resume keeps the database and retrieves only the sites that have no URLs in it, for picking up after an interrupted run.

Command line

Every option takes a value (--show-misses TRUE, never a bare --show-misses), in any order, as --name VALUE or --name=VALUE.
python sitemap-product-matcher.py --help lists them with their defaults.

  • --working-folder-path FOLDER: where the database, the cache and temporary files go; blank: the script’s folder.
  • --urls-file-path FILE, --products-file-path FILE: the two input files; both are needed.
  • --sitemap-mode retrieve|resume|stored: rebuild the database (the default), retrieve only missing sites, or retrieve nothing.
  • --database-file-path FILE: the database, relative to the working folder; blank: <urls>_<products>.db.
  • --candidates-shown N: pages shown for each product, best first (1).
  • --show-misses TRUE|FALSE: also list unmatched products with their best page below --minimum-score (FALSE).
  • --list-sitemaps TRUE|FALSE: list each sitemap read, and the problems reading them (FALSE).
  • --include-url-pattern REGEX, --exclude-url-pattern REGEX: keep only, or leave out, URLs a regular expression finds (/blog/|/news/); blank: no filter.
  • --include-url-text TEXT, --exclude-url-text TEXT: the same with comma-separated texts (/blog/,/news/).
  • --minimum-score SCORE: the lowest score that counts as a match (0.58).
  • --ambiguity-margin SCORE: flag a match when the runner-up is this close (0.03).
  • --candidates-per-product N, --maximum-index-entries N, --full-scan-url-count N: how much of a large site is scored for each product (400, 50000, 5000).
  • --verify-pages TRUE|FALSE: retrieve each matched page and check its product name (FALSE).
  • --verify-bytes-per-page BYTES, --verify-warning-score SCORE: with --verify-pages TRUE, the bytes read from each page and the score below which a page disagrees; blank: 400000 and 0.55.
  • --parallel-fetches N (8), --timeout-seconds SECONDS (20), --delay-seconds SECONDS between requests to one site (0.1), --retries N (2), --backoff-seconds SECONDS (1), --maximum-retry-wait-seconds SECONDS (30).
  • --user-agent TEXT: the User-Agent header; blank: Chrome 124 on Windows.
  • --use-cache TRUE|FALSE (TRUE), --cache-file-path FILE (blank: <database>.cache.db), --cache-reuse-seconds SECONDS to reuse a cached sitemap without asking the server (0), --clear-cache TRUE|FALSE (FALSE).
  • --maximum-sitemaps N for each site (250), --maximum-urls N for each site (0: no limit), --rows-per-write N (2000).

Exit codes: 0 done (also when nothing matched), 1 the task couldn’t be done (a missing input file, a database that can’t be written, curl_cffi missing), 2 a mistake on the command line.

Troubleshooting

  • “cannot overwrite … .db”: the database is open in another program, such as a SQLite browser. Close it, or choose another --database-file-path.
  • “no sitemap URLs stored”: the site has no sitemap where robots.txt or the usual paths say, or refused the requests.
    --list-sitemaps TRUE shows each sitemap tried and what went wrong.
  • Too few matches: check --show-misses TRUE for near misses, then lower --minimum-score, or narrow the URLs to product pages with --include-url-pattern.

Limitations

  • It finds pages only through sitemaps: it doesn’t follow links between pages.
  • The product name comes from the URL, so a site whose product URLs hold only IDs (/p/123456) can’t be matched without --verify-pages TRUE, and even then only the pages already matched are checked.
  • --sitemap-mode retrieve replaces the database at the start of the run, so an interrupted run leaves a partial one.
    --sitemap-mode resume retrieves the sites that have no URLs in it, but keeps a site that was cut off halfway as it is.
⬇️ Download Sitemap Product Matcher.zip27.4 KBLast Updated: November 14, 2026Python

← All AI-created software