Merged both files & made JSON export + README.md update

This commit is contained in:
Jakub Kydlíček 2024-04-24 14:20:17 +02:00
parent fd5f5c667c
commit 604b682f17
4 changed files with 38 additions and 103 deletions

View File

@ -1,6 +1,4 @@
# obedy #Óda na pracovní oběd
Óda na pracovní oběd
V pracovním dni, kdy slunce vysoko stoupá, Když hlad nás k sobě volá, ať jsme kdekoli, Na stole se objeví ten sladký okamžik, Kdy se setkáme s obědem, co nám sílu dodá. V pracovním dni, kdy slunce vysoko stoupá, Když hlad nás k sobě volá, ať jsme kdekoli, Na stole se objeví ten sladký okamžik, Kdy se setkáme s obědem, co nám sílu dodá.

View File

@ -1,39 +0,0 @@
#!/bin/bash
url="https://www.unasplzenchutna.cz/garage/cz/denni-nabidka/"
html_snippet=$(curl -s "$url")
day_of_week=$(date '+%u')
case "$day_of_week" in
1)
soup=$(echo "$html_snippet" | grep -oP '(?<=<h2 class="table">Polévka<\/h2>).*?(?=<\/table>)' | sed 's/<[^>]*>//g' | awk 'NR==1')
main_course=$(echo "$html_snippet" | grep -oP '(?<=<h2 class="table">Hlavní jídlo<\/h2>).*?(?=<\/table>)' | sed 's/<[^>]*>//g' | awk 'NR==1')
;;
2)
soup=$(echo "$html_snippet" | grep -oP '(?<=<h2 class="table">Polévka<\/h2>).*?(?=<\/table>)' | sed 's/<[^>]*>//g' | awk 'NR==2')
main_course=$(echo "$html_snippet" | grep -oP '(?<=<h2 class="table">Hlavní jídlo<\/h2>).*?(?=<\/table>)' | sed 's/<[^>]*>//g' | awk 'NR==2')
;;
3)
soup=$(echo "$html_snippet" | grep -oP '(?<=<h2 class="table">Polévka<\/h2>).*?(?=<\/table>)' | sed 's/<[^>]*>//g' | awk 'NR==3')
main_course=$(echo "$html_snippet" | grep -oP '(?<=<h2 class="table">Hlavní jídlo<\/h2>).*?(?=<\/table>)' | sed 's/<[^>]*>//g' | awk 'NR==3')
;;
4)
soup=$(echo "$html_snippet" | grep -oP '(?<=<h2 class="table">Polévka<\/h2>).*?(?=<\/table>)' | sed 's/<[^>]*>//g' | awk 'NR==4')
main_course=$(echo "$html_snippet" | grep -oP '(?<=<h2 class="table">Hlavní jídlo<\/h2>).*?(?=<\/table>)' | sed 's/<[^>]*>//g' | awk 'NR==4')
;;
4)
soup=$(echo "$html_snippet" | grep -oP '(?<=<h2 class="table">Polévka<\/h2>).*?(?=<\/table>)' | sed 's/<[^>]*>//g' | awk 'NR==5')
main_course=$(echo "$html_snippet" | grep -oP '(?<=<h2 class="table">Hlavní jídlo<\/h2>).*?(?=<\/table>)' | sed 's/<[^>]*>//g' | awk 'NR==5')
;;
*)
echo "Spatnej den v tydnu brasko"
exit 1
;;
esac
echo "Polévka:"
echo "$soup"
echo
echo "Hlavní chod:"
echo "$main_course"

View File

@ -1,39 +0,0 @@
#!/bin/bash
url="https://sladovnicka.unasplzenchutna.cz/cz/denni-nabidka/"
html_snippet=$(curl -s "$url")
day_of_week=$(date '+%u')
case "$day_of_week" in
1)
soup=$(echo "$html_snippet" | grep -oP '(?<=<h2 class="table">Polévka<\/h2>).*?(?=<\/table>)' | sed 's/<[^>]*>//g' | awk 'NR==1')
main_course=$(echo "$html_snippet" | grep -oP '(?<=<h2 class="table">Hlavní jídlo<\/h2>).*?(?=<\/table>)' | sed 's/<[^>]*>//g' | awk 'NR==1')
;;
2)
soup=$(echo "$html_snippet" | grep -oP '(?<=<h2 class="table">Polévka<\/h2>).*?(?=<\/table>)' | sed 's/<[^>]*>//g' | awk 'NR==2')
main_course=$(echo "$html_snippet" | grep -oP '(?<=<h2 class="table">Hlavní jídlo<\/h2>).*?(?=<\/table>)' | sed 's/<[^>]*>//g' | awk 'NR==2')
;;
3)
soup=$(echo "$html_snippet" | grep -oP '(?<=<h2 class="table">Polévka<\/h2>).*?(?=<\/table>)' | sed 's/<[^>]*>//g' | awk 'NR==3')
main_course=$(echo "$html_snippet" | grep -oP '(?<=<h2 class="table">Hlavní jídlo<\/h2>).*?(?=<\/table>)' | sed 's/<[^>]*>//g' | awk 'NR==3')
;;
4)
soup=$(echo "$html_snippet" | grep -oP '(?<=<h2 class="table">Polévka<\/h2>).*?(?=<\/table>)' | sed 's/<[^>]*>//g' | awk 'NR==4')
main_course=$(echo "$html_snippet" | grep -oP '(?<=<h2 class="table">Hlavní jídlo<\/h2>).*?(?=<\/table>)' | sed 's/<[^>]*>//g' | awk 'NR==4')
;;
4)
soup=$(echo "$html_snippet" | grep -oP '(?<=<h2 class="table">Polévka<\/h2>).*?(?=<\/table>)' | sed 's/<[^>]*>//g' | awk 'NR==5')
main_course=$(echo "$html_snippet" | grep -oP '(?<=<h2 class="table">Hlavní jídlo<\/h2>).*?(?=<\/table>)' | sed 's/<[^>]*>//g' | awk 'NR==5')
;;
*)
echo "Spatnej den v tydnu brasko"
exit 1
;;
esac
echo "Polévka:"
echo "$soup"
echo
echo "Hlavní chod:"
echo "$main_course"

View File

@ -1,30 +1,39 @@
#!/bin/bash #!/bin/bash
output=""
get_zradylko() { get_zradylko() {
local url="$1" local url="$1"
local html_snippet=$(curl -s "$url") local html_snippet=$(curl -s "$url")
local day_of_week=$(date '+%u') local day_of_week=$(date '+%u')
restaurant_name=$(echo "$html_snippet" | grep -oP '(?<=<title>).*?(?=</title>)')
case "$day_of_week" in case "$day_of_week" in
1) 1)
soup=$(echo "$html_snippet" | grep -oP '(?<=<h2 class="table">Polévka<\/h2>).*?(?=<\/table>)' | sed 's/<[^>]*>//g' | awk 'NR==1') soup=$(echo "$html_snippet" | grep -oP '(?<=<h2 class="table">Polévka<\/h2>).*?(?=<\/table>)' | sed 's/<[^>]*>//g' | awk 'NR==1')
main_course=$(echo "$html_snippet" | grep -oP '(?<=<h2 class="table">Hlavní jídlo<\/h2>).*?(?=<\/table>)' | sed 's/<[^>]*>//g' | awk 'NR==1') main_course=$(echo "$html_snippet" | grep -oP '(?<=<h2 class="table">Hlavní jídlo<\/h2>).*?(?=<\/table>)' | sed 's/<[^>]*>//g' | awk 'NR==1')
weekly_course=$(echo "$html_snippet" | grep -oP '(?<=<h3>Celý týden nabízíme</h3>).*?(?=<\/table>)' | sed 's/<[^>]*>//g')
;; ;;
2) 2)
soup=$(echo "$html_snippet" | grep -oP '(?<=<h2 class="table">Polévka<\/h2>).*?(?=<\/table>)' | sed 's/<[^>]*>//g' | awk 'NR==2') soup=$(echo "$html_snippet" | grep -oP '(?<=<h2 class="table">Polévka<\/h2>).*?(?=<\/table>)' | sed 's/<[^>]*>//g' | awk 'NR==2')
main_course=$(echo "$html_snippet" | grep -oP '(?<=<h2 class="table">Hlavní jídlo<\/h2>).*?(?=<\/table>)' | sed 's/<[^>]*>//g' | awk 'NR==2') main_course=$(echo "$html_snippet" | grep -oP '(?<=<h2 class="table">Hlavní jídlo<\/h2>).*?(?=<\/table>)' | sed 's/<[^>]*>//g' | awk 'NR==2')
weekly_course=$(echo "$html_snippet" | grep -oP '(?<=<h3>Celý týden nabízíme</h3>).*?(?=<\/table>)' | sed 's/<[^>]*>//g')
;; ;;
3) 3)
soup=$(echo "$html_snippet" | grep -oP '(?<=<h2 class="table">Polévka<\/h2>).*?(?=<\/table>)' | sed 's/<[^>]*>//g' | awk 'NR==3') soup=$(echo "$html_snippet" | grep -oP '(?<=<h2 class="table">Polévka<\/h2>).*?(?=<\/table>)' | sed 's/<[^>]*>//g' | awk 'NR==3')
main_course=$(echo "$html_snippet" | grep -oP '(?<=<h2 class="table">Hlavní jídlo<\/h2>).*?(?=<\/table>)' | sed 's/<[^>]*>//g' | awk 'NR==3') main_course=$(echo "$html_snippet" | grep -oP '(?<=<h2 class="table">Hlavní jídlo<\/h2>).*?(?=<\/table>)' | sed 's/<[^>]*>//g' | awk 'NR==3')
weekly_course=$(echo "$html_snippet" | grep -oP '(?<=<h3>Celý týden nabízíme</h3>).*?(?=<\/table>)' | sed 's/<[^>]*>//g')
;; ;;
4) 4)
soup=$(echo "$html_snippet" | grep -oP '(?<=<h2 class="table">Polévka<\/h2>).*?(?=<\/table>)' | sed 's/<[^>]*>//g' | awk 'NR==4') soup=$(echo "$html_snippet" | grep -oP '(?<=<h2 class="table">Polévka<\/h2>).*?(?=<\/table>)' | sed 's/<[^>]*>//g' | awk 'NR==4')
main_course=$(echo "$html_snippet" | grep -oP '(?<=<h2 class="table">Hlavní jídlo<\/h2>).*?(?=<\/table>)' | sed 's/<[^>]*>//g' | awk 'NR==4') main_course=$(echo "$html_snippet" | grep -oP '(?<=<h2 class="table">Hlavní jídlo<\/h2>).*?(?=<\/table>)' | sed 's/<[^>]*>//g' | awk 'NR==4')
weekly_course=$(echo "$html_snippet" | grep -oP '(?<=<h3>Celý týden nabízíme</h3>).*?(?=<\/table>)' | sed 's/<[^>]*>//g')
;; ;;
5) 5)
soup=$(echo "$html_snippet" | grep -oP '(?<=<h2 class="table">Polévka<\/h2>).*?(?=<\/table>)' | sed 's/<[^>]*>//g' | awk 'NR==5') soup=$(echo "$html_snippet" | grep -oP '(?<=<h2 class="table">Polévka<\/h2>).*?(?=<\/table>)' | sed 's/<[^>]*>//g' | awk 'NR==5')
main_course=$(echo "$html_snippet" | grep -oP '(?<=<h2 class="table">Hlavní jídlo<\/h2>).*?(?=<\/table>)' | sed 's/<[^>]*>//g' | awk 'NR==5') main_course=$(echo "$html_snippet" | grep -oP '(?<=<h2 class="table">Hlavní jídlo<\/h2>).*?(?=<\/table>)' | sed 's/<[^>]*>//g' | awk 'NR==5')
weekly_course=$(echo "$html_snippet" | grep -oP '(?<=<h3>Celý týden nabízíme</h3>).*?(?=<\/table>)' | sed 's/<[^>]*>//g')
;; ;;
*) *)
echo "Spatnej den v tydnu brasko" echo "Spatnej den v tydnu brasko"
@ -32,29 +41,35 @@ get_zradylko() {
;; ;;
esac esac
echo "Polévka:" # Create a JSON object with the desired fields
echo "$soup" output+="{
echo \"title\": \"**$restaurant_name**\",
echo "Hlavní chod:" \"fields\": [
echo "$main_course" {
\"name\": \"Polevka\",
\"value\": \"$soup\"
},
{
\"name\": \"Hlavni chod\",
\"value\": \"$main_course\"
},
{
\"name\": \"Tydenni nabidka\",
\"value\": \"$weekly_course\"
}
]
},"
} }
get_restaurant_name() { # Example usage:
local url="$1" urlGarage="https://www.unasplzenchutna.cz/garage/cz/denni-nabidka/"
local html_snippet=$(curl -s "$url") get_zradylko "$urlGarage"
restaurant_name=$(echo "$html_snippet" | grep -oP '(?<=<title>).*?(?=</title>)')
echo "$restaurant_name"
}
urlOsteria="https://www.unasplzenchutna.cz/garage/cz/denni-nabidka/"
get_restaurant_name "$urlOsteria"
get_zradylko "$urlOsteria"
echo ""
urlSladovnicka="https://sladovnicka.unasplzenchutna.cz/cz/denni-nabidka/" urlSladovnicka="https://sladovnicka.unasplzenchutna.cz/cz/denni-nabidka/"
get_restaurant_name "$urlSladovnicka" get_zradylko "$urlSladovnicka"
get_zradylko "$urlSladovnicka"
# Remove the trailing comma from the menu_data
output="${output%,}"
# Print the complete menu data
echo "[$output]" | jq .