30 lines
618 B
Go
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
|
|
} |