[object Object]

← back to Wolfgordon Crawl

Fix image extraction: capture both CDN paths (/production/images + /production/product/swatches) so signed (200) images aren't lost to the 401 fallback

79044e4dec0efc3e283f52177629eb0fd690b201 · 2026-06-19 10:42:01 -0700 · Steve

Files touched

Diff

commit 79044e4dec0efc3e283f52177629eb0fd690b201
Author: Steve <steve@designerwallcoverings.com>
Date:   Fri Jun 19 10:42:01 2026 -0700

    Fix image extraction: capture both CDN paths (/production/images + /production/product/swatches) so signed (200) images aren't lost to the 401 fallback
---
 scrape-wolfgordon.js | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/scrape-wolfgordon.js b/scrape-wolfgordon.js
index c7ef252..b3bf2c6 100644
--- a/scrape-wolfgordon.js
+++ b/scrape-wolfgordon.js
@@ -173,11 +173,14 @@ function parseProductPage(html, url) {
 
   // Map SKU(dash) -> SIGNED swatch image URL scraped from the page.
   // The unsigned base URL 401s; the page's signed imgix URLs are public + 200.
+  // WG serves signed swatch images under TWO CDN paths: /production/images/<SKU>
+  // and /production/product/swatches/<sku>. Capture both; key by alnum-only SKU.
   const imgMap = {};
-  const imgRe = /https:\/\/cdn2-optimize\.wolfgordon\.com\/production\/images\/([A-Z0-9-]+)\.jpg\?[^"' )]+/g;
+  const nk = s => s.toUpperCase().replace(/[^A-Z0-9]/g, '');
+  const imgRe = /https:\/\/cdn2-optimize\.wolfgordon\.com\/production\/(?:images|product\/swatches)\/([A-Za-z0-9_-]+)\.jpg\?[^"' )]+/g;
   let im;
   while ((im = imgRe.exec(html)) !== null) {
-    const key = im[1].toUpperCase();
+    const key = nk(im[1]);
     if (!imgMap[key]) imgMap[key] = im[0].replace(/&amp;/g, '&');
   }
 
@@ -204,7 +207,7 @@ function parseProductPage(html, url) {
     if (base.toLowerCase().endsWith(mainSlug)) {
       purl = base.slice(0, base.length - mainSlug.length) + slug(c.sku);
     }
-    const img = imgMap[c.sku.toUpperCase().replace(/\s+/g, '-')] || cdnImage(c.sku);
+    const img = imgMap[nk(c.sku)] || cdnImage(c.sku);
     products.push({
       mfr_sku: c.sku,
       pattern_name: productName,

← d88890b Add Phase-2 resumable daily-push.sh driver + launchd plist (  ·  back to Wolfgordon Crawl  ·  Add image-backfill (re-pull signed images via two-path extra f850a62 →