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 title string
|
||||||
var url string
|
var url string
|
||||||
var header *html.Node
|
var header *html.Node
|
||||||
h1, _ := getHtmlElement(article, "h1")
|
h1s, _ := getAllElements(article, "h1")
|
||||||
h2, _ := getHtmlElement(article, "h2")
|
h2s, _ := getAllElements(article, "h2")
|
||||||
h3, _ := getHtmlElement(article, "h3")
|
h3s, _ := getAllElements(article, "h3")
|
||||||
if h1 != nil {
|
if len(h1s) > 0 {
|
||||||
header = h1
|
header = h1s[0]
|
||||||
} else if h2 != nil {
|
} else if len(h2s) > 0 {
|
||||||
header = h2
|
header = h2s[0]
|
||||||
} else if h3 != nil {
|
} else if len(h3s) > 0 {
|
||||||
header = h3
|
header = h3s[0]
|
||||||
}
|
}
|
||||||
if header == nil {
|
if header == nil {
|
||||||
return "", "", nil
|
return "", "", nil
|
||||||
|
|
Loading…
Reference in New Issue