60 lines
2.4 KiB
Bash
Executable File
60 lines
2.4 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
get_zradylko() {
|
|
local url="$1"
|
|
local html_snippet=$(curl -s "$url")
|
|
local 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')
|
|
;;
|
|
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')
|
|
;;
|
|
*)
|
|
echo "Spatnej den v tydnu brasko"
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
echo "Polévka:"
|
|
echo "$soup"
|
|
echo
|
|
echo "Hlavní chod:"
|
|
echo "$main_course"
|
|
}
|
|
|
|
get_restaurant_name() {
|
|
local url="$1"
|
|
local html_snippet=$(curl -s "$url")
|
|
|
|
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/"
|
|
get_restaurant_name "$urlSladovnicka"
|
|
get_zradylko "$urlSladovnicka" |