Browse Source

Merge branch 'master' of angerstoner/mensa into master

vuex
Schneider 7 years ago
committed by Gogs
parent
commit
6b382e7350
  1. 10
      server/server.go

10
server/server.go

@ -7,6 +7,7 @@ import (
"os" "os"
"regexp" "regexp"
"strings" "strings"
"time"
"github.com/PuerkitoBio/goquery" "github.com/PuerkitoBio/goquery"
) )
@ -76,7 +77,14 @@ func writeToFile(content []byte) error {
} }
func operate(mensa string, day int) (Menu, error) { func operate(mensa string, day int) (Menu, error) {
document, err := goquery.NewDocument(fmt.Sprintf("http://www.studentenwerk-goettingen.de/speiseplan.html?no_cache=1&day=%vpush=0&selectmensa=%s", day, mensa))
currentDay := int(time.Now().Weekday()) // week starts on sunday in go, but thats not relevant, because the canteen is closed on sunday
push := 0
if currentDay > day {
push = 1
}
document, err := goquery.NewDocument(fmt.Sprintf("http://www.studentenwerk-goettingen.de/speiseplan.html?no_cache=1&day=%v&push=%v&selectmensa=%s", day, push, mensa))
if err != nil { if err != nil {
return Menu{}, err return Menu{}, err
} }

Loading…
Cancel
Save