Skip to content

Commit

Permalink
[scrape] added more coin games from milan
Browse files Browse the repository at this point in the history
  • Loading branch information
DictumMortuum committed Jul 14, 2024
1 parent 398a6e7 commit 9e7e6df
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 0 deletions.
70 changes: 70 additions & 0 deletions pkg/scrape/COIN_milan.go
Original file line number Diff line number Diff line change
@@ -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
}
2 changes: 2 additions & 0 deletions pkg/scrape/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ var (
"hexasim": ScrapeCOINHexasim,
"udogrebe": ScrapeCOINUdo,
"myfriendsgames": ScrapeMyFriendsGames,
"milan": ScrapeCOINMilan,
}
IDs = map[string]int64{
"avalongames": 25,
Expand Down Expand Up @@ -98,6 +99,7 @@ var (
"hexasim": 44,
"udogrebe": 45,
"myfriendsgames": 46,
"milan": 47,
}
)

Expand Down
2 changes: 2 additions & 0 deletions pkg/scrape/gamerules.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}{
Expand Down

0 comments on commit 9e7e6df

Please sign in to comment.