forked from ardanlabs/gotraining
/
cnn.go
38 lines (28 loc) · 823 Bytes
/
cnn.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package search
import "log"
var cnnFeeds = []string{
"http://rss.cnn.com/rss/cnn_topstories.rss",
"http://rss.cnn.com/rss/cnn_world.rss",
"http://rss.cnn.com/rss/cnn_us.rss",
"http://rss.cnn.com/rss/cnn_allpolitics.rss",
}
// CNN provides support for CNN searches.
type CNN struct{}
// NewCNN returns a CNN Searcher value.
func NewCNN() Searcher {
return CNN{}
}
// Search performs a search against the CNN RSS feeds.
func (CNN) Search(uid string, term string, found chan<- []Result) {
log.Printf("%s : CNN : Search : Started : searchTerm[%s]\n", uid, term)
results := []Result{}
for _, feed := range cnnFeeds {
res, err := rssSearch(uid, term, "CNN", feed)
if err != nil {
continue
}
results = append(results, res...)
}
found <- results
log.Printf("%s : CNN : Search : Completed\n", uid)
}