diff --git a/pkg/scrape/COIN_milan.go b/pkg/scrape/COIN_milan.go new file mode 100644 index 0000000..3d2b611 --- /dev/null +++ b/pkg/scrape/COIN_milan.go @@ -0,0 +1,70 @@ +package scrape + +import ( + "log" + + "github.com/gocolly/colly/v2" +) + +func ScrapeCOINMilan() (map[string]any, []map[string]any, error) { + store_id := int64(47) + rs := []map[string]any{} + + collector := colly.NewCollector( + colly.AllowedDomains("www.milan-spiele.de"), + user_agent, + colly.CacheDir(CacheDir), + ) + + collector.OnHTML(".master", func(e *colly.HTMLElement) { + raw_price := e.ChildText(".priceRow span.price") + + var stock int + if childHasClass(e, ".delivery", "yellow") { + stock = 1 + } else if childHasClass(e, ".delivery", "green") { + stock = 2 + } else { + stock = 0 + } + + name := e.ChildText(".detail h1") + + item := map[string]any{ + "name": name, + "store_id": store_id, + "store_thumb": "https://www.milan-spiele.de/images/gmt-games-logo.jpg", + "stock": stock, + "price": getPrice(raw_price), + "url": e.Request.URL.String(), + "tag": "COIN", + } + + log.Println(item) + + rs = append(rs, item) + }) + + URLs := []string{ + "https://www.milan-spiele.de/-p-28604.html", + "https://www.milan-spiele.de/fire-lake-second-edition-engl-p-17569.html", + "https://www.milan-spiele.de/-p-34822.html", + "https://www.milan-spiele.de/-p-34842.html", + "https://www.milan-spiele.de/-p-33628.html", + "https://www.milan-spiele.de/-p-27345.html", + "https://www.milan-spiele.de/-p-27751.html", + "https://www.milan-spiele.de/-p-32602.html", + } + + for _, item := range URLs { + collector.Visit(item) + } + + collector.Wait() + + return map[string]interface{}{ + "name": "Milan", + "id": store_id, + "scraped": len(rs), + }, rs, nil +} diff --git a/pkg/scrape/common.go b/pkg/scrape/common.go index 601dd54..6673cf2 100644 --- a/pkg/scrape/common.go +++ b/pkg/scrape/common.go @@ -56,6 +56,7 @@ var ( "hexasim": ScrapeCOINHexasim, "udogrebe": ScrapeCOINUdo, "myfriendsgames": ScrapeMyFriendsGames, + "milan": ScrapeCOINMilan, } IDs = map[string]int64{ "avalongames": 25, @@ -98,6 +99,7 @@ var ( "hexasim": 44, "udogrebe": 45, "myfriendsgames": 46, + "milan": 47, } ) diff --git a/pkg/scrape/gamerules.go b/pkg/scrape/gamerules.go index acdbe0d..ef03c82 100644 --- a/pkg/scrape/gamerules.go +++ b/pkg/scrape/gamerules.go @@ -58,6 +58,8 @@ func ScrapeGameRules() (map[string]any, []map[string]any, error) { collector.Visit("https://www.thegamerules.com/epitrapezia-paixnidia?fa132=Board%20Game%20Expansions") collector.Visit("https://www.thegamerules.com/epitrapezia-paixnidia?fa132=Board%20Games") + collector.Visit("https://www.thegamerules.com/preorders?fa132=Board%20Games") + collector.Visit("https://www.thegamerules.com/preorders?fa132=Board%20Game%20Expansions") collector.Wait() return map[string]interface{}{