BharatKalluri
5/29/2017 - 12:33 PM

A simple go pgm

A simple go pgm

package main

import (
	"encoding/json"
	"fmt"
	"github.com/PuerkitoBio/goquery"
	"log"
)

type Opposite struct {
	hero    string `json:oppname`
	percent int64  `json:percent`
}

type Hero struct {
	name string     `json:name`
	Opp  []Opposite `json:opposite`
}

func main() {
	doc, err := goquery.NewDocument("https://www.dotabuff.com/heroes/abaddon/matchups")
	if err != nil {
		log.Fatal(err)
	}
	ob := Hero{
		name: "abaddon",
		opp: [100] Opposite,
	}
	opp.append(Opposite{
		hero: "am",
		percent: -1.8,
	})
	fmt.Println(string(ob))
	doc.Find(".cell-xlarge").Each(func(i int, s *goquery.Selection) {
		hero := s.Find("a").Text()
		percent := s.Next().Text()
	})
}