forked from ardanlabs/gotraining
-
Notifications
You must be signed in to change notification settings - Fork 1
/
bbc.go
38 lines (28 loc) · 850 Bytes
/
bbc.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 bbcFeeds = []string{
"http://feeds.bbci.co.uk/news/rss.xml",
"http://feeds.bbci.co.uk/news/world/rss.xml",
"http://feeds.bbci.co.uk/news/politics/rss.xml",
"http://feeds.bbci.co.uk/news/world/us_and_canada/rss.xml",
}
// BBC provides support for BBC searches.
type BBC struct{}
// NewBBC returns a BBC Searcher value.
func NewBBC() Searcher {
return BBC{}
}
// Search performs a search against the CNN RSS feeds.
func (BBC) Search(uid string, term string, found chan<- []Result) {
log.Printf("%s : BBC : Search : Started : searchTerm[%s]\n", uid, term)
results := []Result{}
for _, feed := range bbcFeeds {
res, err := rssSearch(uid, term, "BBC", feed)
if err != nil {
continue
}
results = append(results, res...)
}
found <- results
log.Printf("%s : BBC : Search : Completed\n", uid)
}