make it so it doesnt crash but just logs output

This commit is contained in:
zongor 2024-08-19 22:27:34 -04:00
parent 0dfbeea8d3
commit 96cff5792c
1 changed files with 3 additions and 2 deletions

View File

@ -7,6 +7,7 @@ import (
"os"
"time"
"bufio"
"strings"
"github.com/mmcdole/gofeed"
)
@ -23,9 +24,9 @@ func main () {
s := bufio.NewScanner(os.Stdin)
for s.Scan() {
fp := gofeed.NewParser()
feed, err := fp.ParseURLWithContext(s.Text(), ctx)
feed, err := fp.ParseURLWithContext(strings.TrimSpace(s.Text()), ctx)
if err != nil {
log.Fatal(err)
log.Println(err)
} else {
for _, item := range feed.Items {
fmt.Printf("<li><a href=\"%s\">%s</a><p>%s</p></li>\n", item.Link, item.Title, item.Description)