about summary refs log tree commit diff
path: root/cmd
diff options
context:
space:
mode:
authorFranck Cuny <franck@fcuny.net>2024-04-28 19:15:51 -0700
committerFranck Cuny <franck@fcuny.net>2024-04-28 19:17:12 -0700
commit58d0a9cb616e35daf115b8e1aa9f5b79e4a21a70 (patch)
tree87f0cb04b860048f70c2f90cf9ba9d7d5e7f2634 /cmd
parentchore: update flake (diff)
downloadworld-58d0a9cb616e35daf115b8e1aa9f5b79e4a21a70.tar.gz
add a script to fetch cheeseboard's menu
Delete the version in go.
Diffstat (limited to 'cmd')
-rw-r--r--cmd/cbpt/main.go57
1 files changed, 0 insertions, 57 deletions
diff --git a/cmd/cbpt/main.go b/cmd/cbpt/main.go
deleted file mode 100644
index 075f084..0000000
--- a/cmd/cbpt/main.go
+++ /dev/null
@@ -1,57 +0,0 @@
-package main
-
-import (
-	"fmt"
-	"regexp"
-	"strings"
-
-	"github.com/gocolly/colly"
-)
-
-const (
-	cheeseboardURL = "https://cheeseboardcollective.coop/pizza/"
-)
-
-var (
-	boilerPlateParBake      = regexp.MustCompile(`Parbake pizza is available in the bakery from \d a.m. to \d p.m., while supplies last.`)
-	boilerPlateParBakeLunch = regexp.MustCompile(`Parbake pizza is available in the bakery from \d a.m. to \d p.m..Lunch from 1\d:30-\d:30 and dinner from \d-\d.`)
-	boilerPlateNoHotPizza   = regexp.MustCompile(`No hot pizza today.`)
-	cheeseboardIsClosed     = regexp.MustCompile(`The Pizzeria is closed today`)
-)
-
-type Pizza struct {
-	Date     string
-	Toppings string
-}
-
-func main() {
-	c := colly.NewCollector()
-
-	c.OnRequest(func(r *colly.Request) {
-		fmt.Println("Visiting", r.URL)
-	})
-
-	var pizzas []Pizza
-
-	c.OnHTML("div.pizza-list", func(e *colly.HTMLElement) {
-		e.ForEach("article", func(c int, el *colly.HTMLElement) {
-			var pizza Pizza
-			pizza.Date = el.ChildText("div.date")
-			toppings := el.ChildText("div.menu > p:nth-child(2)")
-			if cheeseboardIsClosed.MatchString(toppings) {
-				return
-			}
-			toppings = boilerPlateParBake.ReplaceAllString(toppings, "")
-			toppings = boilerPlateParBakeLunch.ReplaceAllString(toppings, "")
-			toppings = boilerPlateNoHotPizza.ReplaceAllString(toppings, "")
-			toppings = strings.TrimLeft(toppings, " ")
-			pizza.Toppings = toppings
-			pizzas = append(pizzas, pizza)
-		})
-	})
-
-	c.Visit(cheeseboardURL)
-	for _, pizza := range pizzas {
-		fmt.Printf("%s: %s\n", pizza.Date, pizza.Toppings)
-	}
-}