From 892615719751c3640b1b9c9d6d0e1954c87373e4 Mon Sep 17 00:00:00 2001 From: jpchapiewsky Date: Mon, 23 Dec 2024 16:22:29 -0600 Subject: [PATCH] add georgie porgies --- importer/sites.json | 6 ++++++ importer/sites/georgie.ts | 27 +++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 importer/sites/georgie.ts diff --git a/importer/sites.json b/importer/sites.json index 797168a..91ba0c8 100644 --- a/importer/sites.json +++ b/importer/sites.json @@ -107,6 +107,12 @@ "url" : "https://www.popscustard.com/", "script": "./sites/pops.ts", "flavorOfTheDay": "" + }, + { + "name": "Georgie Porgies", + "url" : "https://georgieporgies.com/georgies-flavor-forecast/", + "script": "./sites/georgie.ts", + "flavorOfTheDay": "" } ] } \ No newline at end of file diff --git a/importer/sites/georgie.ts b/importer/sites/georgie.ts new file mode 100644 index 0000000..b396567 --- /dev/null +++ b/importer/sites/georgie.ts @@ -0,0 +1,27 @@ +/// +import { Browser } from "https://deno.land/x/puppeteer@16.2.0/vendor/puppeteer-core/puppeteer/common/Browser.js"; +import { MkeFrozenTreatsImporter } from "../importer.interface.ts"; + +export async function load(browser: Browser, site: MkeFrozenTreatsImporter.Site): Promise { + console.log('Loading Georgie Porgies...'); + const page = await browser.newPage(); + page.emulateTimezone('America/Chicago'); + + await page.goto(site.url); + + const todayH2 = await page.waitForXPath(`//h2[contains(text(), "Today")]`, { timeout: 2000 }); + const todayDivEl = await page.evaluateHandle(element => + element.closest('div.et_pb_column'), todayH2 + ); + + + const flavorOfTheDay = await todayDivEl.$$eval('img', options => { + return options.map(option => option.getAttribute('alt')); + }); + if(flavorOfTheDay.length > 0) { + const flavorOfTheDayText = flavorOfTheDay[0].replace('Flavor of the Day - ', ''); + return flavorOfTheDayText; + } + + return ''; +} \ No newline at end of file