package main import ( log "github.com/Sirupsen/logrus" ) func (app *App) ScrapeHTML(shops []Shop) { wait := make(chan bool) count := 0 for _, shop := range shops { go app.Scrape(shop, wait) count++ } /* Wait until all go routines finished */ for i := 0; i < count; i++ { <-wait } } func (app *App) Scrape(shop Shop, wait chan bool) { var W []Angebot var err error W = app.ScrapeShop(shop) W = sanitize_offer(W, shop) err = app.save_offer(W) if err != nil { Warn(err, "Saving offers failed") } err = app.remove_expired(W, shop) if err != nil { Warn(err, "Removing expired offers failed") } wait <- true } func (app *App) ScrapeShop(shop Shop) []Angebot { switch shop.Name { case "Bottleworld": return app.ScrapeBottleWord(shop) case "MC Whisky": return app.ScrapeMCWhisky(shop) case "Rum & Co": return app.ScrapeRumundCo(shop) case "Whic": return app.ScrapeWhic(shop) case "Whisky.de": return app.ScrapeWhiskyde(shop) case "Whiskysite.nl": return app.ScrapeWhiskysitenl(shop) case "Whisky World": return app.ScrapeWhiskyworld(shop) case "Whiskyzone": return app.ScrapeWhiskyzone(shop) default: log.Println(shop.Name + ": No Crawler") } return []Angebot{} }