Skip to content

Instantly share code, notes, and snippets.

@julianshen
Created October 4, 2016 16:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save julianshen/2c21aa1e83e1e7b20f0d2560600383f2 to your computer and use it in GitHub Desktop.
Save julianshen/2c21aa1e83e1e7b20f0d2560600383f2 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"github.com/SlyMarbo/rss"
"github.com/julianshen/go-readability"
"github.com/parnurzeal/gorequest"
"github.com/yanyiwu/gojieba"
)
func main() {
x := gojieba.NewJieba()
defer x.Free()
feed, err := rss.Fetch("https://tw.news.yahoo.com/rss/finance")
if err != nil {
// handle error.
fmt.Println(err)
panic(1)
}
request := gorequest.New()
for _, item := range feed.Items {
_, body, err := request.Get(item.Link).End()
if err == nil {
doc, err := readability.NewDocument(body)
if err == nil {
keywords := x.ExtractWithWeight(doc.Text(), 5)
fmt.Println(keywords)
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment