Skip to content

Instantly share code, notes, and snippets.

@rkbodenner
Created June 23, 2016 05:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rkbodenner/af7dd861edb89ce3a884c4da627bf86a to your computer and use it in GitHub Desktop.
Save rkbodenner/af7dd861edb89ce3a884c4da627bf86a to your computer and use it in GitHub Desktop.
Scrape game information from GPSD site
package main
import (
"fmt"
"strings"
"github.com/PuerkitoBio/goquery"
)
func main() {
doc, _ := goquery.NewDocument("http://www.gpsdsoccer.com/teams/81495074/57845445-81495140/TEAM.html")
doc.Find("tr.GameRow").Each(func(i int, s *goquery.Selection) {
date := s.Find("td.date").Text()
time := s.Find("td.time").Text()
opponent := s.Find("td.tm1 a").Text()
if opponent == "" {
opponent = s.Find("td.tm2 a").Text()
}
facility := s.Find("td.facility a").Text()
opponent = strings.TrimSpace(opponent)
facility = strings.TrimSpace(facility)
fmt.Printf("%s %s vs. %s at %s\n", date, time, opponent, facility)
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment