From 065ea870dafb4cbcf293e40ccf4600a51b403504 Mon Sep 17 00:00:00 2001 From: Clarence Chan Date: Thu, 28 Sep 2023 11:51:13 -0400 Subject: [PATCH] Continue scrape when a fight list item's formatting is broken on the UFC event page --- scrape.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/scrape.js b/scrape.js index dcc836c6..89509b3e 100644 --- a/scrape.js +++ b/scrape.js @@ -37,7 +37,15 @@ async function getDetailsFromEventLink(url) { let prelims = []; function convertLiToStr(li) { - let bout = li.querySelector(".c-listing-fight__class-text").innerText; + let bout = li.querySelector(".c-listing-fight__class-text")?.innerText; + if (!bout) + return ( + "• " + + li + .querySelector(".field--name-node-title") + .innerText.trim() + .replace(" vs ", " vs. ") + ); if (bout.includes("Strawweight")) bout = "115"; else if (bout.includes("Flyweight")) bout = "125"; else if (bout.includes("Bantamweight")) bout = "135";