Created
June 23, 2016 05:18
-
-
Save rkbodenner/af7dd861edb89ce3a884c4da627bf86a to your computer and use it in GitHub Desktop.
Scrape game information from GPSD site
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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