Files
wire/internal/articles/articles.go
2026-05-25 09:21:24 -04:00

50 lines
681 B
Go

package articles
import (
"log"
"wire/internal/api"
)
type Articles []Article
type Article struct {
Title string
Link string
Description string
Content string
}
type ArticleParser struct {
url string
limit int
}
func NewParser(url string) *ArticleParser {
ap := ArticleParser{
url: url,
limit: 15,
}
return &ap
}
func (ap *ArticleParser) GetArticles() (as Articles) {
items, err := api.FetchRSS(ap.url)
if err != nil {
log.Fatal(err)
}
for i, v := range items {
if i == ap.limit {
break
}
as = append(as, Article{
Title: v.Title,
Link: v.Link,
Description: v.Description,
Content: v.Content,
})
}
return
}