mirror of
https://github.com/gocsaf/csaf.git
synced 2025-12-22 11:55:40 +01:00
Re-started link checker for directory listings
This commit is contained in:
parent
d5d48c7d2e
commit
32be3602b6
5 changed files with 114 additions and 28 deletions
33
cmd/csaf_checker/links.go
Normal file
33
cmd/csaf_checker/links.go
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
// This file is Free Software under the MIT License
|
||||
// without warranty, see README.md and LICENSES/MIT.txt for details.
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
//
|
||||
// SPDX-FileCopyrightText: 2022 German Federal Office for Information Security (BSI) <https://www.bsi.bund.de>
|
||||
// Software-Engineering: 2022 Intevation GmbH <https://intevation.de>
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"io"
|
||||
|
||||
"github.com/PuerkitoBio/goquery"
|
||||
)
|
||||
|
||||
func linksOnPage(r io.Reader) ([]string, error) {
|
||||
|
||||
doc, err := goquery.NewDocumentFromReader(r)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var links []string
|
||||
|
||||
doc.Find("a").Each(func(i int, s *goquery.Selection) {
|
||||
if link, ok := s.Attr("href"); ok {
|
||||
links = append(links, link)
|
||||
}
|
||||
})
|
||||
|
||||
return links, nil
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue