|
@ -13,19 +13,20 @@ import ( |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
type ( |
|
|
type ( |
|
|
// Meal contains the info about a meals
|
|
|
|
|
|
Meal struct { |
|
|
|
|
|
Category string `json:"category"` |
|
|
|
|
|
Price string `json:"price"` |
|
|
|
|
|
Title string `json:"title"` |
|
|
|
|
|
} |
|
|
|
|
|
// Menu contains all info to menues in a mensa on one day
|
|
|
|
|
|
Menu struct { |
|
|
|
|
|
Day int `json:"day"` |
|
|
|
|
|
Mensa string `json:"mensa"` |
|
|
|
|
|
Meals []Meal `json:"meals"` |
|
|
|
|
|
Date string `json:"date"` |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// Meal contains the info about a meals
|
|
|
|
|
|
Meal struct { |
|
|
|
|
|
Category string `json:"category"` |
|
|
|
|
|
Price string `json:"price"` |
|
|
|
|
|
Title string `json:"title"` |
|
|
|
|
|
Diet string `json:"diet"` |
|
|
|
|
|
} |
|
|
|
|
|
// Menu contains all info to menues in a mensa on one day
|
|
|
|
|
|
Menu struct { |
|
|
|
|
|
Day int `json:"day"` |
|
|
|
|
|
Mensa string `json:"mensa"` |
|
|
|
|
|
Meals []Meal `json:"meals"` |
|
|
|
|
|
Date string `json:"date"` |
|
|
|
|
|
} |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
var ( |
|
|
var ( |
|
@ -107,13 +108,15 @@ func strip(old string) string { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func parseMeals(doc *goquery.Document) ([]Meal, error) { |
|
|
func parseMeals(doc *goquery.Document) ([]Meal, error) { |
|
|
meals := []Meal{} |
|
|
|
|
|
doc.Find("table.speise-tblmain tbody tr").Each(func(i int, s *goquery.Selection) { |
|
|
|
|
|
meal := Meal{ |
|
|
|
|
|
Category: strip(s.Find(".ext_sits_preis").Text()), // yes, really preis
|
|
|
|
|
|
Title: strip(s.Find(".ext_sits_essen").Text()), |
|
|
|
|
|
} |
|
|
|
|
|
meals = append(meals, meal) |
|
|
|
|
|
}) |
|
|
|
|
|
return meals, nil |
|
|
|
|
|
|
|
|
meals := []Meal{} |
|
|
|
|
|
doc.Find("table.speise-tblmain tbody tr").Each(func(i int, s *goquery.Selection) { |
|
|
|
|
|
diet, _ := s.Find(".ext_sits_speiseplan_icon").Children().Attr("alt") |
|
|
|
|
|
meal := Meal{ |
|
|
|
|
|
Category: strip(s.Find(".ext_sits_preis").Text()), // yes, really preis
|
|
|
|
|
|
Title: strip(s.Find(".ext_sits_essen").Text()), |
|
|
|
|
|
Diet: strip(diet), |
|
|
|
|
|
} |
|
|
|
|
|
meals = append(meals, meal) |
|
|
|
|
|
}) |
|
|
|
|
|
return meals, nil |
|
|
} |
|
|
} |