Browse Source

added diet to json

master
angerstoner 7 years ago
parent
commit
22ef696692
  1. 3
      server/server.go

3
server/server.go

@ -18,6 +18,7 @@ type (
Category string `json:"category"` Category string `json:"category"`
Price string `json:"price"` Price string `json:"price"`
Title string `json:"title"` Title string `json:"title"`
Diet string `json:"diet"`
} }
// Menu contains all info to menues in a mensa on one day // Menu contains all info to menues in a mensa on one day
Menu struct { Menu struct {
@ -109,9 +110,11 @@ func strip(old string) string {
func parseMeals(doc *goquery.Document) ([]Meal, error) { func parseMeals(doc *goquery.Document) ([]Meal, error) {
meals := []Meal{} meals := []Meal{}
doc.Find("table.speise-tblmain tbody tr").Each(func(i int, s *goquery.Selection) { 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{ meal := Meal{
Category: strip(s.Find(".ext_sits_preis").Text()), // yes, really preis Category: strip(s.Find(".ext_sits_preis").Text()), // yes, really preis
Title: strip(s.Find(".ext_sits_essen").Text()), Title: strip(s.Find(".ext_sits_essen").Text()),
Diet: strip(diet),
} }
meals = append(meals, meal) meals = append(meals, meal)
}) })

Loading…
Cancel
Save