gobeaver

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

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

Go to latest
Published: Dec 7, 2014 License: MIT Imports: 7 Imported by: 0

README

GoBeaver

A Go package for programmatically working with the London School of Economics and Political Science (LSE) course guide (unofficial API).

The GoBeaver library uses GoQuery to extract and synthesise (web scraping) data from the LSE course guide documents. The data are then stored in a Go struct (for each individual course) and a slice (for a collection of courses) which can be programmatically accessed and manipulated.

For example, generator/generator.go in this repository idiomatically dumps all the course information that are stored in a slice and struct via Go's JSON serialization library.

Installation

The GoBeaver package is comprised of a library and a runnable binary, generator/generator.go in this repo.

To install the library:

$ go get github.com/MrSaints/gobeaver

(Optional) To install and run the generator:

$ go get github.com/MrSaints/gobeaver/generator
$ go run generator.go

Usage / Examples

See generator/generator.go in this repo.

Boring Stuff

The MrSaints/GoBeaver project is NEITHER AFFILIATED WITH NOR ENDORSED BY the LSE university and/or its student union (LSE SU).

It is a personal project which exposes a rudimentary API for accessing and manipulating publicly available course information. No personal credentials are collected and/or stored.

Please use this project at your own discretion.

Licensing

The MIT License (MIT) / LICENSE

Copyright (C) 2014, Ian Lai.

Documentation

Index

Constants

View Source
const LSE_URL = "http://www.lse.ac.uk"

Variables

View Source
var PROGRAMMES_URL = map[string]string{
	"Undergraduate": LSE_URL + "/resources/calendar/courseGuides/undergraduate.htm",
	"Graduate":      LSE_URL + "/resources/calendar/courseGuides/graduate.htm",
	"Research":      LSE_URL + "/resources/calendar/courseGuides/research.htm",
}

Functions

func BuildURL

func BuildURL(absolute, relative string) string

Construct URL to course

func FormatProperty

func FormatProperty(paragraphs *goquery.Selection) string

func GetDocument

func GetDocument(url string) (program *goquery.Document)

func ProgramAtoi

func ProgramAtoi(program_type string) (program_code int)

Types

type Course

type Course struct {
	Code          string
	Title         string
	URL           string
	Department    string
	Students      int
	Class         int
	Value         float32
	Teachers      []string // TODO: "Additional Teachers" and paragraphs (regexp)
	Availability  string   // TODO: Store in array (compulsory, optional, others)
	Prerequisites string
	Content       string // TODO: Handle lists?
	Teaching      string // TODO: Store in array (MT, LT, ST)
	Formative     string
	Readings      string
	Assessments   string
	Program       int
}

Course structure

func BuildCourse

func BuildCourse(s *goquery.Selection, program_type string) (course *Course)

func GetCourse

func GetCourse(code string) (course *Course)

Get information for a specified course using a course code

func (*Course) GetProperties

func (this *Course) GetProperties() *Course

Build properties for a course (TODO: Implement channels?)

type Courses

type Courses []*Course

Course collection

func GetAllCourses

func GetAllCourses() (all_courses Courses)

Build course collection for all programmes

func GetCourses

func GetCourses(program_type string) (program_courses Courses)

Build course collection for a specified program

func (Courses) GetProperties

func (this Courses) GetProperties() Courses

Build properties for all courses

func (Courses) Len

func (slice Courses) Len() int

Sort interface

func (Courses) Less

func (slice Courses) Less(i, j int) bool

func (Courses) Swap

func (slice Courses) Swap(i, j int)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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