blob: d07abc868c2e8d7d02e3057935c022041add805f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
#!/usr/bin/env python3
from textwrap import fill
import requests
from bs4 import BeautifulSoup
from termcolor import colored
from prettytable import PrettyTable
url = "https://cheeseboardcollective.coop/pizza/"
def main():
content = requests.get(url)
soup = BeautifulSoup(content.text, "html.parser")
magic_ingredients = ["corn"]
table = PrettyTable()
table.field_names = ["date", "pizza"]
table.align = "l"
pizzas = soup.select(".pizza-list > article")
for pizza in pizzas:
date_color = "white"
menu_color = "white"
date = pizza.find(class_="date").text
# the pizza is the 1st element, the 2nd is the salad, and i don't
# care about the salad :)
menu = pizza.select(".menu > p:nth-of-type(1)")[0].get_text(strip=True, separator="\n").split("\n")
if "closed" in menu[0]:
date_color = "red"
if "Parbake pizza is available" in menu[0]:
menu.pop(0)
if "Lunch from" in menu[0]:
menu.pop(0)
if "No hot pizza today" in menu[0]:
menu.pop(0)
final_menu = "".join(menu)
for ingredient in magic_ingredients:
if ingredient in final_menu:
menu_color = "yellow"
table.add_row([colored(date, date_color), fill(colored(final_menu, menu_color), width=80)])
print(table)
|