summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/scrapers/fad-yokohama.ts9
-rw-r--r--app/scrapers/pitbar-nishiogikubo.ts4
2 files changed, 6 insertions, 7 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);
diff --git a/app/scrapers/pitbar-nishiogikubo.ts b/app/scrapers/pitbar-nishiogikubo.ts
index 2553002..569ce26 100644
--- a/app/scrapers/pitbar-nishiogikubo.ts
+++ b/app/scrapers/pitbar-nishiogikubo.ts
@@ -38,10 +38,10 @@ async function extractEvents(page: Page, dateFrom: string, dateTo: string): Prom
return Array.from(cells).map((el) => {
const id = el.getAttribute("id") ?? "";
const parts = id.split("-");
- // id: cal-25771-YYYY-M-D
+ // id: cal-25771-YYYY-M-D (sometimes suffixed with _clone after JS cloning)
const year = parts[2];
const month = parts[3];
- const day = parts[4];
+ const day = parts[4]?.replace(/\D.*$/, "");
if (!year || !month || !day) return null;
return {
date: `${year}-${month.padStart(2, "0")}-${day.padStart(2, "0")}`,