correct rss to null check the author
This commit is contained in:
parent
852db161c9
commit
f1f2142fdf
@ -2,7 +2,7 @@ package input
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
@ -35,7 +35,7 @@ func getHttpContent(uri string) ([]byte, error) {
|
|||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
body, err := ioutil.ReadAll(resp.Body)
|
body, err := io.ReadAll(resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,11 @@ func (rc rssClient) GetArticles() ([]domain.ArticleEntity, error) {
|
|||||||
Description: post.Content,
|
Description: post.Content,
|
||||||
Url: post.Link,
|
Url: post.Link,
|
||||||
PubDate: *post.PublishedParsed,
|
PubDate: *post.PublishedParsed,
|
||||||
AuthorName: post.Author.Email,
|
//AuthorName: post.Authors[0].Email,
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(post.Authors) != 0 {
|
||||||
|
article.AuthorName = post.Authors[0].Email
|
||||||
}
|
}
|
||||||
|
|
||||||
var postTags []string
|
var postTags []string
|
||||||
@ -47,6 +51,21 @@ func (rc rssClient) GetArticles() ([]domain.ArticleEntity, error) {
|
|||||||
postTags = append(postTags, post.Categories...)
|
postTags = append(postTags, post.Categories...)
|
||||||
article.Tags = strings.Join(postTags, ",")
|
article.Tags = strings.Join(postTags, ",")
|
||||||
|
|
||||||
|
/*
|
||||||
|
pageContent, err := getHttpContent(article.Url)
|
||||||
|
if err != nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
htmlNode, err := html.Parse(bytes.NewReader(pageContent))
|
||||||
|
if err != nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
htmlNode.
|
||||||
|
|
||||||
|
fmt.Println(htmlNode)
|
||||||
|
*/
|
||||||
|
|
||||||
if post.Image == nil {
|
if post.Image == nil {
|
||||||
article.Thumbnail = ""
|
article.Thumbnail = ""
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user