pcgamedb/utils/keeplinks.go

23 lines
461 B
Go
Raw Normal View History

2024-09-24 06:17:11 -04:00
package utils
import (
"bytes"
"fmt"
"strings"
"github.com/PuerkitoBio/goquery"
)
2024-12-02 03:17:01 -05:00
func SolveKeepLinks(URL string) (string, error) {
id := URL[strings.LastIndex(URL, "/")+1:]
resp, err := Request().SetHeader("Cookie", fmt.Sprintf("flag[%s]", id)+"=1").Get(URL)
2024-09-24 06:17:11 -04:00
if err != nil {
return "", err
}
2024-12-02 03:17:01 -05:00
doc, err := goquery.NewDocumentFromReader(bytes.NewReader(resp.Body()))
2024-09-24 06:17:11 -04:00
if err != nil {
return "", err
}
return doc.Find(".livelbl a").Text(), nil
}