Repository navigation
Expand file tree
/
Copy patharticles.go
More file actions
76 lines (60 loc) · 1.93 KB
/
Copy patharticles.go
File metadata and controls
76 lines (60 loc) · 1.93 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package nhk
import (
"NewsChannel/news"
)
func (a *nhk) GetArticles() ([]news.Article, error) {
var articles []news.Article
temp, err := a.GetNationalArticles()
if err != nil {
return nil, err
}
articles = append(articles, temp...)
temp, err = a.GetInternationalArticles()
if err != nil {
return nil, err
}
articles = append(articles, temp...)
temp, err = a.GetSportsArticles()
if err != nil {
return nil, err
}
articles = append(articles, temp...)
temp, err = a.GetEntertainmentArticles()
if err != nil {
return nil, err
}
articles = append(articles, temp...)
temp, err = a.GetBusinessArticles()
if err != nil {
return nil, err
}
articles = append(articles, temp...)
temp, err = a.GetTechnologyArticles()
if err != nil {
return nil, err
}
articles = append(articles, temp...)
return articles, nil
}
func (a *nhk) GetNationalArticles() ([]news.Article, error) {
return a.getArticles("https://www.nhk.or.jp/rss/news/cat0.xml", news.NationalNews)
}
func (a *nhk) GetInternationalArticles() ([]news.Article, error) {
return a.getArticles("https://www.nhk.or.jp/rss/news/cat6.xml", news.InternationalNews)
}
func (a *nhk) GetSportsArticles() ([]news.Article, error) {
return a.getArticles("https://www.nhk.or.jp/rss/news/cat7.xml", news.Sports)
}
func (a *nhk) GetEntertainmentArticles() ([]news.Article, error) {
return a.getArticles("https://www.nhk.or.jp/rss/news/cat2.xml", news.Entertainment)
}
func (a *nhk) GetBusinessArticles() ([]news.Article, error) {
return a.getArticles("https://www.nhk.or.jp/rss/news/cat5.xml", news.Business)
}
func (a *nhk) GetScienceArticles() ([]news.Article, error) {
return a.getArticles("https://www.nhk.or.jp/rss/news/cat3.xml", news.Science)
}
func (a *nhk) GetTechnologyArticles() ([]news.Article, error) {
// This is actually "Society", please sketch change the name of the topic if possible :3
return a.getArticles("https://www.nhk.or.jp/rss/news/cat1.xml", news.Technology)
}