diff options
| author | Maximilian Möhring | 2021-01-21 19:59:26 +0100 |
|---|---|---|
| committer | Maximilian Möhring | 2021-01-21 19:59:26 +0100 |
| commit | 6911e96674917577bb498b94c1aa2ac63653c1a6 (patch) | |
| tree | e7863220cb1865649d7512c8329018fd930863d9 | |
| parent | 8ddc20450040543d8ec2f854943272c94565685e (diff) | |
| download | alkobote-6911e96674917577bb498b94c1aa2ac63653c1a6.tar.gz | |
Detects spirit_type on Whic correctly.
| -rw-r--r-- | crawler/shop_whic.go | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/crawler/shop_whic.go b/crawler/shop_whic.go index 0df7caf..03ceab7 100644 --- a/crawler/shop_whic.go +++ b/crawler/shop_whic.go @@ -23,7 +23,6 @@ func (app *App) ScrapeWhic(shop Shop) []Angebot { W := Angebot{} W.Shop = shop.Id - W.Spirit_type = "Whisky" whisky_name := e.ChildAttr("a", "title") whisky_url := e.ChildAttr("a", "href") @@ -95,6 +94,9 @@ func (app *App) ScrapeWhic(shop Shop) []Angebot { return } + spirit_type_noisy := e.Request.Ctx.Get("spirit_type") + W.Spirit_type = detect_spirit_type(spirit_type_noisy) + W.Website = e.Request.Ctx.Get("website") Whiskys = append(Whiskys, W) @@ -127,6 +129,15 @@ func (app *App) ScrapeWhic(shop Shop) []Angebot { e.Request.Ctx.Put("website", string(e.Response.Body)) }) + c.OnHTML("#product-attribute-specs-table", func(e *colly.HTMLElement) { + e.ForEach("tr", func(i int, e *colly.HTMLElement) { + th_str := e.ChildText("th") + if "Produkt Kategorie" == th_str { + e.Request.Ctx.Put("spirit_type", e.ChildText("td")) + } + }) + }) + err := c.Visit(Shop_url) if err != nil { shop.error_msg = err.Error() |
