Scrape ranking info from TBA
Signed-off-by: Yash Chainani <yashchainani28@gmail.com>
Change-Id: Ib20a770452f5a713ae6aef76233cb0d899b58e8e
diff --git a/scouting/scraping/scraping_demo.go b/scouting/scraping/scraping_demo.go
index 0ea3e53..69cdbff 100644
--- a/scouting/scraping/scraping_demo.go
+++ b/scouting/scraping/scraping_demo.go
@@ -13,22 +13,43 @@
func main() {
jsonPtr := flag.Bool("json", false, "If set, dump as JSON, rather than Go debug output.")
+ demoCategory := flag.String("category", "matches", "Decide whether to demo matches or rankings.")
+
flag.Parse()
- // Get all the matches.
- matches, err := scraping.AllMatches(2016, "nytr", "")
- if err != nil {
- log.Fatal("Failed to scrape match list: ", err)
- }
-
- // Dump the matches.
- if *jsonPtr {
- jsonData, err := json.MarshalIndent(matches, "", " ")
+ if *demoCategory == "rankings" {
+ // Get all the rankings.
+ rankings, err := scraping.AllRankings(2016, "nytr", "")
if err != nil {
- log.Fatal("Failed to turn match list into JSON: ", err)
+ log.Fatal("Failed to scrape ranking list: ", err)
}
- fmt.Println(string(jsonData))
- } else {
- spew.Dump(matches)
+
+ // Dump the rankings.
+ if *jsonPtr {
+ jsonData, err := json.MarshalIndent(rankings, "", " ")
+ if err != nil {
+ log.Fatal("Failed to turn ranking list into JSON: ", err)
+ }
+ fmt.Println(string(jsonData))
+ } else {
+ spew.Dump(rankings)
+ }
+ } else if *demoCategory == "matches" {
+ // Get all the matches.
+ matches, err := scraping.AllMatches(2016, "nytr", "")
+ if err != nil {
+ log.Fatal("Failed to scrape match list: ", err)
+ }
+
+ // Dump the matches.
+ if *jsonPtr {
+ jsonData, err := json.MarshalIndent(matches, "", " ")
+ if err != nil {
+ log.Fatal("Failed to turn match list into JSON: ", err)
+ }
+ fmt.Println(string(jsonData))
+ } else {
+ spew.Dump(matches)
+ }
}
}