get first header element

This commit is contained in:
yequari 2024-04-18 11:45:00 -07:00
parent 282820cc02
commit 5343a8b653
1 changed files with 9 additions and 9 deletions

View File

@ -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