diff --git a/scripts/seed.js b/scripts/seed.js index 7a0e74d..bd23a86 100644 --- a/scripts/seed.js +++ b/scripts/seed.js @@ -35,14 +35,18 @@ function skuFromHref(href, index) { function parseCatalogCards(html) { const cards = []; - const cardRegex = - /]*class="[^"]*product-card[^"]*"[^>]*href="([^"]+)"[^>]*>[\s\S]*?
([\s\S]*?)<\/div>\s*
([\s\S]*?)<\/div>/g; + const cardRegex = /]*)class="[^"]*product-card[^"]*"([^>]*)>([\s\S]*?)<\/a>/g; let match; while ((match = cardRegex.exec(html)) !== null) { - const href = match[1]; - const title = normalizeText(match[2]); - const type = normalizeText(match[3]); + const attrs = `${match[1]} ${match[2]}`; + const body = match[3]; + const hrefMatch = attrs.match(/href="([^"]+)"/); + const titleMatch = body.match(/
([\s\S]*?)<\/div>/); + const typeMatch = body.match(/
([\s\S]*?)<\/div>/); + const href = hrefMatch?.[1] ?? ''; + const title = normalizeText(titleMatch?.[1] ?? ''); + const type = normalizeText(typeMatch?.[1] ?? ''); if (!title) { continue; }