Created
October 4, 2016 16:07
-
-
Save julianshen/2c21aa1e83e1e7b20f0d2560600383f2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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