blob: ae63e5c191b471a6d22dddc96cd1df3a90044c9c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
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{}
}
|