nu

package module
Version: v0.0.0-...-a402645 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2016 License: MIT Imports: 5 Imported by: 0

README

nu

Go Library for scraping NU.nl RSS feed to JSON output

XML is crap. Really. There are no excuses. XML is nasty to parse for humans, and it's a disaster to parse even for computers. There's just no reason for that horrible crap to exist. - Linus Torvalds

##Example

package main

import (
	"fmt"
	"github.com/Rivalo/nu"
)

func main() {
	json, err := nu.JSON("http://www.nu.nl/rss/Algemeen")
  	if err != nil {
  		fmt.Println(err)
  		return
  	}
  
	fmt.Println(string(json))
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func JSON

func JSON(url string) (JSON []byte, err error)

JSON returns the NU RSS feed as JSON in []byte

Types

type Article

type Article struct {
	Title       string     `xml:"title" json:"title"`
	Link        string     `json:"link"`
	Description string     `xml:"description" json:"description"`
	PubData     string     `xml:"pubDate" json:"pubdate"`
	GUID        int        `xml:"guid" json:"guid"`
	Categories  []string   `xml:"category" json:"categories"`
	Creator     string     `xml:"creator" json:"creator"`
	Rights      string     `xml:"rights" json:"rights"`
	Image       Enclosure  `xml:"enclosure" json:"image"`
	Related     []AtomLink `xml:"http://www.w3.org/2005/Atom link" json:"related"`
}

Article constains information of single Nu.nl article

type AtomLink struct {
	Link  string `xml:"href,attr"`
	Title string `xml:"title,attr"`
}

AtomLink contains reference articles

type Channel

type Channel struct {
	Title         string    `xml:"title" json:"title"`
	Description   string    `xml:"description" json:"description"`
	Language      string    `xml:"language" json:"language"`
	Copyright     string    `xml:"copyright" json:"copyright"`
	LastBuildDate string    `xml:"lastBuildDate" json:"lastbuilddate"`
	Item          []Article `xml:"item" json:"item"`
}

Channel contains channel of NUXML feed

type Enclosure

type Enclosure struct {
	Link string `xml:"url,attr" json:"url"`
}

Enclosure contains image of article

type XML

type XML struct {
	Channel Channel `xml:"channel"`
}

XML is a struct containing Nu.nl RSS file

func Struct

func Struct(url string) (feed XML, err error)

Struct returns the NU RSS feed as struct XML

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL