summaryrefslogtreecommitdiff
path: root/app/scrapers/fad-yokohama.ts
diff options
context:
space:
mode:
authoryyamashita <yyamashita@hetzner.yyamashita.com>2026-06-18 12:51:55 +0900
committeryyamashita <yyamashita@hetzner.yyamashita.com>2026-06-18 12:51:55 +0900
commit272f7d079cbac81c9af86b9f210ace8cabc0e98c (patch)
treeb1489cfe1628ded107d02839ebaed53b551211ef /app/scrapers/fad-yokohama.ts
parent243d222c35f4607ac13a400e827333f44a0f44c7 (diff)
Fix HTML entity leakage in FAD scraper and Pitbar _clone date bug
fad-yokohama: replace innerHTML manipulation with Cheerio .clone().text() so that HTML entities (&nbsp; etc.) are decoded before storing titles. pitbar-nishiogikubo: strip non-numeric suffix from day part of element ID to handle _clone-suffixed IDs that freecalend.com generates after JS renders. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'app/scrapers/fad-yokohama.ts')
-rw-r--r--app/scrapers/fad-yokohama.ts9
1 files changed, 4 insertions, 5 deletions
diff --git a/app/scrapers/fad-yokohama.ts b/app/scrapers/fad-yokohama.ts
index f8f7cbc..ddf3fb7 100644
--- a/app/scrapers/fad-yokohama.ts
+++ b/app/scrapers/fad-yokohama.ts
@@ -71,11 +71,10 @@ function parsePageEvents(
const $firstP = $b("p").first();
if (!$firstP.length) continue;
- // Get text with <br/> as newlines
- const rawHtml = $firstP.html() ?? "";
- const lines = rawHtml
- .replace(/<br\s*\/?>/gi, "\n")
- .replace(/<[^>]+>/g, " ")
+ // Get text with <br/> as newlines; use Cheerio .text() to decode HTML entities
+ const $clone = $firstP.clone();
+ $clone.find("br").replaceWith("\n");
+ const lines = $clone.text()
.split("\n")
.map((l) => l.replace(/\s+/g, " ").trim())
.filter(Boolean);