Skip to content

Instantly share code, notes, and snippets.

@rkbodenner

rkbodenner/main.go

Created Jun 23, 2016
Embed
What would you like to do?
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
You can’t perform that action at this time.