scraper

package module
v0.0.0-...-bd66b48 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 1, 2015 License: MIT Imports: 7 Imported by: 0

README

GotSport.com HTML Screen Scraper

This is a GoLang library that parses schedule information from the www.gotsport.com website. It currently parses the schedule page, ie: http://events.gotsport.com/events/schedule.aspx and provides a list of games in a JSON enabled GoLang struct.

Usage

Here is a simple program that queries for a tournement schedule and pretty-prints the results as JSON.

package main

import (
	"encoding/json"
	"fmt"

	"github.com/ericdaugherty/gotsport-scraper"
)

func main() {

	params := map[string]string{
		"EventID": "15267",
		"GroupID": "166875",
		"Gender":  "Boys",
		"Age":     "12",
	}

	schedule, err := scraper.GetSchedule(params)
	if err != nil {
		fmt.Println("Error Occured:", err)
	}
	bytes, err := json.MarshalIndent(schedule, "", "  ")
	if err != nil {
		fmt.Println("Error Occured:", err)
	}

	fmt.Println("Schedule:", string(bytes))
}

License

This code is available for use under the MIT License. See the LICENSE file.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Game

type Game struct {
	Date      time.Time `json:"date"`
	Number    string    `json:"gameNum"`
	HomeTeam  string    `json:"homeTeam"`
	HomeScore string    `json:"homeScore"`
	AwayTeam  string    `json:"awayTeam"`
	AwayScore string    `json:"awayScore"`
}

Game represnts the data for a given game.

type Schedule

type Schedule struct {
	Games []Game `json:"games"`
}

Schedule represents the schedule data parsed from the http://events.gotsport.com/events/schedule.aspx page.

func GetSchedule

func GetSchedule(params map[string]string) (*Schedule, error)

GetSchedule queries the http://events.gotsport.com/events/schedule.aspx page and parses the HTML into a Schedule struct. Parameters should match the URL parameters to pass. Ex: params := map[string]string{ "EventID": "123", "GroupID": "123", "Gender": "Boys", "Age": "10", }

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL