rss

package module
v0.0.0-...-636fa23 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2022 License: Unlicense Imports: 5 Imported by: 0

README

go-rss

Simple RSS parser, tested with various feeds.

Usage

See the example folder.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InsecureRead

func InsecureRead(url string, reddit bool) (*http.Response, error)

InsecureRead reads without certificate check

func Read

func Read(url string, reddit bool) (*http.Response, error)

Read a string url and returns a Channel struct, error

func ReadWithClient

func ReadWithClient(url string, client *http.Client, reddit bool) (*http.Response, error)

ReadWithClient a string url and custom client that must match the Fetcher interface returns a Channel struct, error

Types

type Channel

type Channel struct {
	Title         string `xml:"title"`
	Link          string `xml:"link"`
	Description   string `xml:"description"`
	Language      string `xml:"language"`
	LastBuildDate Date   `xml:"lastBuildDate"`
	Item          []Item `xml:"item"`
}

Channel struct for RSS

func Regular

func Regular(resp *http.Response) (*Channel, error)

Regular parses regular feeds

type Date

type Date string

Date type

func (Date) Format

func (d Date) Format(format string) (string, error)

Format (Date function), takes a string and returns string, error

func (Date) MustFormat

func (d Date) MustFormat(format string) string

MustFormat (Date function), take a string and returns string

func (Date) Parse

func (d Date) Parse() (time.Time, error)

Parse (Date function) and returns Time, error

func (Date) ParseWithFormat

func (d Date) ParseWithFormat(format string) (time.Time, error)

ParseWithFormat (Date function), takes a string and returns Time, error

type Entry

type Entry struct {
	ID      string `xml:"id"`
	Title   string `xml:"title"`
	Updated string `xml:"updated"`
}

Entry struct for each Entry in the Feed

type Feed

type Feed struct {
	Entry []Entry `xml:"entry"`
}

Feed struct for RSS

func Atom

func Atom(resp *http.Response) (*Feed, error)

Atom parses atom feeds

type Fetcher

type Fetcher interface {
	Get(url string) (resp *http.Response, err error)
}

Fetcher interface

type Item

type Item struct {
	Title       string          `xml:"title"`
	Link        string          `xml:"link"`
	Comments    string          `xml:"comments"`
	PubDate     Date            `xml:"pubDate"`
	GUID        string          `xml:"guid"`
	Category    []string        `xml:"category"`
	Enclosure   []ItemEnclosure `xml:"enclosure"`
	Description string          `xml:"description"`
	Author      string          `xml:"author"`
	Content     string          `xml:"content"`
	FullText    string          `xml:"full-text"`
}

Item struct for each Item in the Channel

type ItemEnclosure

type ItemEnclosure struct {
	URL  string `xml:"url,attr"`
	Type string `xml:"type,attr"`
}

ItemEnclosure struct for each Item Enclosure

type Video

type Video struct {
	ID        string `xml:"yt:videoId"`
	Title     string `xml:"title"`
	Published Date   `xml:"published"`
}

ItemEnclosure struct for each Item Enclosure

type YouTubeChannel

type YouTubeChannel struct {
	Name   string  `xml:"title"`
	Link   string  `xml:"link"`
	Videos []Video `xml:"entry"`
}

Channel struct for RSS

func YouTube

func YouTube(resp *http.Response) (*YouTubeChannel, error)

YouTube parses YouTube channel feeds

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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