GithubHelp home page GithubHelp logo

feedreader's Introduction

Feedreader

Feedreader is a Go package for parsing RSS 2.0 and Atom 1.0 feed.

Feedreader on github: http://github.com/m3ng9i/feedreader

Below is an example, it parse a feed, then print feed title, number of items and all the title of items.

package main

import "fmt"
import "os"
import "github.com/m3ng9i/feedreader"

func main() {
    feed, err := feedreader.Fetch("http://example.com/feed.xml")
    if err != nil {
        fmt.Fprintln(os.Stderr, err)
    } else {
        fmt.Println("feed title: ", feed.Title)

        fmt.Printf("There are %d item(s) in the feed\n", len(feed.Items))
        for _, i := range(feed.Items) {
            fmt.Println(i.Title)
        }
    }
}

Function Fetch could parse a feed whatever it is RSS or Atom, it return a Feed structure.

For more information, just read the code. First you should read Feed, FeedItem and FeedPerson structure. If you want parse RSS or Atom from scratch, you need to read the rest code of the package.

If you want to know more about RSS and Atom, read the specification below:

中文说明

Feedreader包可以解析RSS 2.0与Atom 1.0标准的feed。使用方法可以看上面的例子,然后看一下FeedFeedItemFeedPerson的结构。如果要了解完整的功能,可以把包里代码都读一下。

如果RSS或Atom的xml中包含特殊字符,这个包会先将其去除,再进行解析。因此不会出现类似XML syntax error on line XXX: illegal character code U+XXXX这样的错误。

因为有些功能我用不上,也就没有实现这些功能:

不支持Atom的feed/entry/source节点。

不支持RSS的以下节点:

channel/category
channel/docs
channel/cloud
channel/rating
channel/textInput
channel/item/category
channel/item/source

我编写这个包参考了下面的规范:

feedreader's People

Contributors

m3ng9i avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

jameswei akkagao

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.