Implement Parsing of Multiple Articles on one Page #5
18
feed/feed.go
18
feed/feed.go
|
@ -141,15 +141,15 @@ func getTitleAndUrl(article *html.Node) (string, string, error) {
|
|||
var title string
|
||||
var url string
|
||||
var header *html.Node
|
||||
h1, _ := getHtmlElement(article, "h1")
|
||||
h2, _ := getHtmlElement(article, "h2")
|
||||
h3, _ := getHtmlElement(article, "h3")
|
||||
if h1 != nil {
|
||||
header = h1
|
||||
} else if h2 != nil {
|
||||
header = h2
|
||||
} else if h3 != nil {
|
||||
header = h3
|
||||
h1s, _ := getAllElements(article, "h1")
|
||||
h2s, _ := getAllElements(article, "h2")
|
||||
h3s, _ := getAllElements(article, "h3")
|
||||
if len(h1s) > 0 {
|
||||
header = h1s[0]
|
||||
} else if len(h2s) > 0 {
|
||||
header = h2s[0]
|
||||
} else if len(h3s) > 0 {
|
||||
header = h3s[0]
|
||||
}
|
||||
if header == nil {
|
||||
return "", "", nil
|
||||
|
|
Loading…
Reference in New Issue