Initial commit
This commit is contained in:
commit
3091d4759b
8 changed files with 4881 additions and 0 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
venv/
|
4
download_html.sh
Executable file
4
download_html.sh
Executable file
|
@ -0,0 +1,4 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
wget https://www.lekkervanbijons.be/groenten/seizoenskalender-groenten -O seizoenskalender-groenten.html
|
||||
wget https://www.lekkervanbijons.be/fruit/seizoenskalender-fruit -O seizoenskalender-fruit.html
|
16
fruit.json
Normal file
16
fruit.json
Normal file
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"Aardbei": [1, 1, 2, 3, 3, 3, 3, 3, 3, 2, 2, 1],
|
||||
"Appel": [3, 3, 3, 3, 3, 3, 2, 2, 3, 3, 3, 3],
|
||||
"Blauwe bes": [0, 0, 0, 1, 2, 3, 3, 2, 2, 2, 0, 0],
|
||||
"Braambes": [0, 0, 0, 1, 2, 3, 3, 3, 2, 2, 2, 1],
|
||||
"Cassisbes": [0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0],
|
||||
"Framboos": [0, 0, 0, 1, 2, 3, 3, 3, 2, 2, 1, 0],
|
||||
"Kers": [0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0],
|
||||
"Kiwibes": [0, 0, 0, 0, 0, 0, 0, 1, 3, 2, 0, 0],
|
||||
"Kweepeer": [2, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2],
|
||||
"Peer": [3, 3, 3, 2, 2, 2, 1, 1, 3, 3, 3, 3],
|
||||
"Pruim": [0, 0, 0, 0, 0, 0, 3, 3, 2, 1, 0, 0],
|
||||
"Rode bes": [0, 0, 0, 0, 0, 2, 3, 3, 2, 1, 1, 0],
|
||||
"Stekelbes": [0, 0, 0, 0, 1, 1, 3, 3, 1, 0, 0, 0],
|
||||
"Veenbes": [0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2]
|
||||
}
|
59
groenten.json
Normal file
59
groenten.json
Normal file
|
@ -0,0 +1,59 @@
|
|||
{
|
||||
"Aardpeer": [2, 2, 1, 1, 0, 0, 0, 0, 0, 1, 2, 3],
|
||||
"Ajuin": [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],
|
||||
"Andijvie": [0, 0, 1, 2, 2, 2, 2, 2, 3, 3, 2, 1],
|
||||
"Artisjok": [0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 0, 0],
|
||||
"Asperge (groen)": [0, 0, 0, 2, 3, 2, 1, 0, 0, 0, 0, 0],
|
||||
"Asperge (wit)": [0, 1, 2, 2, 3, 2, 1, 0, 0, 0, 0, 0],
|
||||
"Aubergine": [0, 1, 1, 2, 3, 3, 3, 2, 2, 1, 1, 0],
|
||||
"Augurk": [0, 0, 0, 1, 2, 2, 3, 3, 3, 2, 0, 0],
|
||||
"Bloemkool": [1, 1, 1, 1, 2, 3, 2, 2, 3, 2, 1, 1],
|
||||
"Boerenkool": [3, 3, 2, 0, 0, 0, 0, 0, 1, 2, 2, 2],
|
||||
"Boontjes": [0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0],
|
||||
"Broccoli": [0, 0, 0, 0, 1, 2, 2, 2, 3, 2, 1, 1],
|
||||
"Broccolini": [0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0],
|
||||
"Champignon": [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3],
|
||||
"Chinese kool": [2, 2, 2, 1, 2, 1, 1, 1, 2, 2, 2, 2],
|
||||
"Courgette": [0, 0, 1, 1, 2, 3, 3, 3, 3, 2, 1, 0],
|
||||
"Erwtjes": [0, 0, 0, 0, 1, 3, 2, 1, 0, 0, 0, 0],
|
||||
"Friseline": [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],
|
||||
"Groene boontjes": [0, 0, 1, 1, 2, 2, 3, 3, 2, 1, 0, 0],
|
||||
"Knolselder": [3, 3, 3, 3, 3, 3, 2, 1, 2, 2, 3, 3],
|
||||
"Komkommer": [1, 1, 2, 3, 3, 3, 3, 3, 2, 1, 1, 1],
|
||||
"Koolrabi": [0, 0, 0, 0, 1, 2, 2, 2, 3, 3, 3, 1],
|
||||
"Krulandijvie": [0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2],
|
||||
"Lente-uitjes": [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],
|
||||
"Oesterzwam": [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3],
|
||||
"Paksoi": [1, 1, 2, 2, 3, 3, 3, 3, 3, 3, 2, 2],
|
||||
"Paprika": [0, 0, 1, 2, 2, 3, 3, 3, 2, 1, 0, 0],
|
||||
"Pastinaak": [3, 3, 3, 2, 1, 0, 0, 1, 1, 2, 3, 3],
|
||||
"Peterselie": [1, 1, 1, 1, 2, 3, 3, 3, 3, 3, 2, 2],
|
||||
"Pompoen": [1, 1, 1, 2, 2, 2, 1, 1, 3, 3, 3, 2],
|
||||
"Postelein": [0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 0, 0],
|
||||
"Prei": [3, 3, 3, 3, 2, 2, 2, 2, 3, 3, 3, 3],
|
||||
"Raap": [3, 3, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3],
|
||||
"Rabarber": [0, 1, 1, 2, 3, 3, 3, 2, 1, 1, 0, 0],
|
||||
"Radicchio Rosso": [0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 0],
|
||||
"Radijsjes": [1, 1, 2, 2, 3, 3, 2, 2, 2, 2, 2, 2],
|
||||
"Rammenas": [3, 2, 2, 1, 1, 1, 1, 0, 1, 3, 3, 3],
|
||||
"Rode biet": [3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 3],
|
||||
"Rode kool": [3, 3, 3, 3, 1, 1, 1, 1, 2, 3, 3, 3],
|
||||
"Savooikool": [3, 3, 2, 1, 1, 1, 1, 2, 3, 3, 3, 3],
|
||||
"Schorseneren": [3, 3, 2, 1, 0, 0, 0, 0, 2, 3, 3, 3],
|
||||
"Selder": [1, 0, 0, 1, 2, 3, 3, 3, 3, 3, 2, 1],
|
||||
"Shii-take": [2, 2, 2, 2, 2, 1, 1, 1, 2, 3, 3, 3],
|
||||
"Sjalot": [2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2],
|
||||
"Sla": [2, 2, 3, 3, 3, 2, 2, 2, 2, 2, 3, 3],
|
||||
"Spinazie": [1, 1, 1, 2, 3, 3, 2, 2, 3, 3, 2, 1],
|
||||
"Spitskool": [1, 1, 0, 0, 2, 2, 1, 1, 2, 2, 1, 1],
|
||||
"Spruitjes": [3, 3, 2, 1, 0, 0, 0, 1, 2, 3, 3, 3],
|
||||
"Tomaat": [1, 1, 2, 2, 3, 3, 3, 3, 3, 3, 1, 1],
|
||||
"Tuinkers": [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],
|
||||
"Venkel": [0, 0, 0, 1, 2, 3, 3, 3, 3, 3, 1, 0],
|
||||
"Warmoes / snijbiet": [0, 0, 0, 0, 1, 2, 2, 2, 2, 1, 0, 0],
|
||||
"Waterkers": [3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3],
|
||||
"Witloof": [3, 3, 3, 2, 2, 1, 1, 1, 2, 3, 3, 3],
|
||||
"Witte kool": [3, 3, 2, 2, 1, 2, 1, 1, 3, 3, 3, 3],
|
||||
"Wortelen": [1, 1, 0, 1, 2, 3, 3, 3, 3, 3, 2, 1],
|
||||
"Zoete aardappel": [3, 3, 3, 2, 0, 0, 0, 0, 0, 1, 2, 3]
|
||||
}
|
55
html_to_json.py
Executable file
55
html_to_json.py
Executable file
|
@ -0,0 +1,55 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
from bs4 import BeautifulSoup
|
||||
import json
|
||||
|
||||
|
||||
LEVELS = ["", "light", "normal", "dark"]
|
||||
|
||||
|
||||
def level_from_classes(classes):
|
||||
for class_ in classes:
|
||||
try:
|
||||
return LEVELS.index(class_)
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
# Site likes to mess with us: class="active normal" is the same as class="active"
|
||||
if "active" in classes:
|
||||
return LEVELS.index("normal")
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
def from_tr(tr):
|
||||
name = tr.find(class_="productcalendar__product").a.text
|
||||
|
||||
month_tds = tr.find_all("td")[2:]
|
||||
months = [level_from_classes(td.get("class", "")) for td in month_tds]
|
||||
|
||||
assert len(months) == 12
|
||||
|
||||
return name, months
|
||||
|
||||
|
||||
def calendar_from_soup(soup):
|
||||
return {
|
||||
name: months
|
||||
for name, months
|
||||
in map(from_tr, soup.find(class_="productcalendar")("tr"))
|
||||
}
|
||||
|
||||
|
||||
def html_to_json(fname_in, fname_out):
|
||||
with open(fname_in) as f_in:
|
||||
soup = BeautifulSoup(f_in, "html.parser")
|
||||
with open(fname_out, "w") as f_out:
|
||||
json.dump(calendar_from_soup(soup), f_out)
|
||||
|
||||
|
||||
def main():
|
||||
html_to_json("./seizoenskalender-groenten.html", "./groenten.json")
|
||||
html_to_json("./seizoenskalender-fruit.html", "./fruit.json")
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
1
requirements.txt
Normal file
1
requirements.txt
Normal file
|
@ -0,0 +1 @@
|
|||
beautifulsoup4==4.9.3
|
1356
seizoenskalender-fruit.html
Normal file
1356
seizoenskalender-fruit.html
Normal file
File diff suppressed because one or more lines are too long
3389
seizoenskalender-groenten.html
Normal file
3389
seizoenskalender-groenten.html
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue