diff options
author | Adam Mathes <adam@trenchant.org> | 2017-11-19 21:23:04 -0700 |
---|---|---|
committer | Adam Mathes <adam@trenchant.org> | 2017-11-19 21:23:04 -0700 |
commit | 741cd94da338e00e2eee0e12d572e04c3be46530 (patch) | |
tree | 46367e8fd8d79f0bdde64d3f0e689f51cd8f64fb /crawler | |
parent | 0d249e198e8f3b5a18f655794776cf656dcda0c2 (diff) | |
download | neko-741cd94da338e00e2eee0e12d572e04c3be46530.tar.gz neko-741cd94da338e00e2eee0e12d572e04c3be46530.tar.bz2 neko-741cd94da338e00e2eee0e12d572e04c3be46530.zip |
enable full_text and header_image
Diffstat (limited to 'crawler')
-rw-r--r-- | crawler/crawler.go | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/crawler/crawler.go b/crawler/crawler.go index ea9f694..e84e219 100644 --- a/crawler/crawler.go +++ b/crawler/crawler.go @@ -1,21 +1,20 @@ package crawler import ( - "log" "adammathes.com/neko/models/feed" "adammathes.com/neko/models/item" + "adammathes.com/neko/vlog" + "github.com/mmcdole/gofeed" + "log" "net/http" "time" - "github.com/mmcdole/gofeed" - "adammathes.com/neko/vlog" ) - func Crawl() { ch := make(chan string) - feeds,err := feed.All() + feeds, err := feed.All() if err != nil { log.Fatal(err) } @@ -64,7 +63,7 @@ func CrawlFeed(f *feed.Feed, ch chan<- string) { // a lot of RSS2.0 generated by wordpress and others // uses <content:encoded> - e,ok := i.Extensions["content"]["encoded"] + e, ok := i.Extensions["content"]["encoded"] var encoded = "" if ok { encoded = e[0].Value @@ -73,16 +72,18 @@ func CrawlFeed(f *feed.Feed, ch chan<- string) { item.Description = encoded } - if(i.PublishedParsed != nil) { + if i.PublishedParsed != nil { item.PublishDate = i.PublishedParsed.Format("2006-01-02 15:04:05") } else { item.PublishDate = time.Now().Format("2006-01-02 15:04:05") } - + item.FeedId = f.Id err := item.Create() if err != nil { vlog.Println(err) + } else { + item.GetFullContent() } } ch <- "successfully crawled " + f.Url + "\n" |