diff options
| author | horus | 2019-05-07 16:04:41 +0200 |
|---|---|---|
| committer | horus | 2019-05-07 16:04:41 +0200 |
| commit | a347c584e0e650219d71941990302c4be558da22 (patch) | |
| tree | 0842697207c5cd744d3c0964f870f791590d96a7 /crawler/shop_drankdozijn.go | |
| parent | 21fa504804b35e689adcb89c483ae2a8deb82d83 (diff) | |
| download | alkobote-a347c584e0e650219d71941990302c4be558da22.tar.gz | |
Better spirit type detection. (crawler)
Diffstat (limited to 'crawler/shop_drankdozijn.go')
| -rw-r--r-- | crawler/shop_drankdozijn.go | 48 |
1 files changed, 42 insertions, 6 deletions
diff --git a/crawler/shop_drankdozijn.go b/crawler/shop_drankdozijn.go index 850f462..b60aaa8 100644 --- a/crawler/shop_drankdozijn.go +++ b/crawler/shop_drankdozijn.go @@ -68,6 +68,21 @@ func (app *App) ScrapeDrankdozijn(shop Shop) []Angebot { W.Name = api_data["saleDescription"].(string) tmp_desc := api_data["group"].(map[string]interface{}) + + tmp_spirit_type := tmp_desc["description"].(string) + + if "Bier" == tmp_spirit_type { + DebugOffer(W, "Drankdozijn: skip offer because it's beer") + continue + } + + /* + if "Wein" == tmp_spirit_type { + DebugOffer(W, "Drankdozijn: skip offer because it's wine") + continue + } + */ + W.Spirit_type = detect_spirit_type(tmp_desc["description"].(string)) //v, ok := api_data["price"] @@ -132,7 +147,7 @@ func (app *App) ScrapeDrankdozijn(shop Shop) []Angebot { */ if strings.Contains(W.Name, "+ gratis") || strings.Contains(W.Name, "& gratis") { - DebugOffer(W, "Drankdozijn: Skip Offer") + DebugOffer(W, "Drankdozijn: Skip Offer because it contains gratis ware") return } @@ -205,7 +220,7 @@ func (app *App) ScrapeDrankdozijn(shop Shop) []Angebot { } }) - c.OnHTML(".main_description", func(e *colly.HTMLElement) { + c.OnHTML(".row .main_description", func(e *colly.HTMLElement) { //log.Println(".main_price") prev := "" count := 0 @@ -236,14 +251,35 @@ func (app *App) ScrapeDrankdozijn(shop Shop) []Angebot { case "Kategorie", "Categorie": //e.Request.Ctx.Put("spirit_type", e.Text) tmp_type := e.Text - if tmp_type == "Likör" { + tmp_type = detect_spirit_type(tmp_type) + + if "Champagner" == tmp_type { + W.Spirit_type = tmp_type + } else if "Cognac" == W.Spirit_type { + if "Calvados" == tmp_type { + W.Spirit_type = tmp_type + } + } + + /* + DebugOffer(W, tmp_type) switch tmp_type { + case "Champagner", "Champagne": + W.Spirit_type = "Champagner" case "Tequila": W.Spirit_type = "Tequila" } - } + */ + /* + if tmp_type == "Likör" { + switch tmp_type { + case "Tequila": + W.Spirit_type = "Tequila" + } + } - if tmp_type == "Wein" { + if tmp_type == "Wein" { + } switch tmp_type { case "Champagner", "Champagne": W.Spirit_type = "Champagner" @@ -251,7 +287,7 @@ func (app *App) ScrapeDrankdozijn(shop Shop) []Angebot { DebugOffer(W, "Drankdozijn: Skip Offer") return } - } + */ } prev = "" |
