Files
wowdoc-scraper/html-parser.go
2024-11-05 23:22:38 +01:00

30 lines
618 B
Go

package main
import (
"fmt"
"strings"
"github.com/PuerkitoBio/goquery"
)
func ParseHTML(html string) ([]string, error) {
res := []string{}
doc, err := goquery.NewDocumentFromReader(strings.NewReader(html))
if err != nil {
return res, fmt.Errorf("failed parsing html: %v", err)
}
doc.Find("tr > td > a").Each(func(i int, s *goquery.Selection) {
href, exists := s.Attr("href")
if !exists {
Warning.Printf("href not found for element %v", s)
return
}
res = append(res, href)
})
return res, nil
}
func ParseDoc(html string) ([]string, error) {
return nil, nil
}