diff options
Diffstat (limited to 'main.go')
| -rw-r--r-- | main.go | 50 |
1 files changed, 39 insertions, 11 deletions
@@ -25,7 +25,7 @@ type App struct { type Angebot struct { Id int Name string - Shop string + Shop int Url string Original_price int Discounted_price int @@ -35,6 +35,7 @@ type Angebot struct { } type Shop struct { + Id int Name string Url string Logo_url string @@ -72,7 +73,17 @@ func main() { log.Fatal(err) } - W := ScrapeHTML() + err = app.insertShops() + if err != nil { + log.Fatal(err) + } + + shops, err := app.getShops() + if err != nil { + log.Fatal(err) + } + + W := ScrapeHTML(shops) err = app.save_offer(W) if err != nil { @@ -98,15 +109,32 @@ func printName(W []Angebot, name string) { fmt.Println(string(output)) } -func ScrapeHTML() []Angebot { - W := ScrapeBottleWord() - W = append(W, ScrapeMCWhisky()...) - W = append(W, ScrapeRumundCo()...) - W = append(W, ScrapeWhic()...) - W = append(W, ScrapeWhiskyde()...) - W = append(W, ScrapeWhiskysitenl()...) - W = append(W, ScrapeWhiskyworld()...) - W = append(W, ScrapeWhiskyzone()...) +func ScrapeHTML(shops []Shop) []Angebot { + var W []Angebot + + for _, shop := range shops { + + switch shop.Name { + case "Bottleworld": + W = append(W, ScrapeBottleWord(shop)...) + case "MC Whisky": + W = append(W, ScrapeMCWhisky(shop)...) + case "Rum & Co": + W = append(W, ScrapeRumundCo(shop)...) + case "Whic": + W = append(W, ScrapeWhic(shop)...) + case "Whisky.de": + W = append(W, ScrapeWhiskyde(shop)...) + case "Whiskysite.nl": + W = append(W, ScrapeWhiskysitenl(shop)...) + case "Whisky World": + W = append(W, ScrapeWhiskyworld(shop)...) + case "Whiskyzone": + W = append(W, ScrapeWhiskyzone(shop)...) + default: + log.Println(shop.Name + ": No Crawler") + } + } return W } |
