-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
41 lines (30 loc) · 871 Bytes
/
main.go
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
package main
import (
"fmt"
"github.com/gocolly/colly"
)
type currentGame struct {
Name string `json:"name"`
Url string `json:"url"`
ImageUrl string `json:"imageUrl"`
}
const baseUrl = "https://backloggd.com"
const username = "BACKLOGGD_USERNAME_HERE"
func main() {
var currentGames []currentGame
c := colly.NewCollector()
c.OnHTML("div.rating-hover", func(e *colly.HTMLElement) {
game := currentGame{}
game.Name = e.ChildText("div.game-text-centered")
partialUrl := e.ChildAttr("a", "href")
game.Url = baseUrl + partialUrl
game.ImageUrl = e.ChildAttr("img", "src")
currentGames = append(currentGames, game)
})
c.Visit(baseUrl + "/u/" + username + "/playing/")
for i := range currentGames {
fmt.Printf("%v\n", currentGames[i].Name)
fmt.Printf("%v\n", currentGames[i].Url)
fmt.Printf("%v\n", currentGames[i].ImageUrl)
}
}