pcgamedb/utils/keeplinks.go

28 lines
493 B
Go
Raw Normal View History

2024-09-24 06:17:11 -04:00
package utils
import (
"bytes"
"fmt"
"strings"
"github.com/PuerkitoBio/goquery"
)
func SolveKeepLinks(url string) (string, error) {
id := url[strings.LastIndex(url, "/")+1:]
resp, err := Fetch(FetchConfig{
Url: url,
Cookies: map[string]string{
fmt.Sprintf("flag[%s]", id): "1",
},
})
if err != nil {
return "", err
}
doc, err := goquery.NewDocumentFromReader(bytes.NewReader(resp.Data))
if err != nil {
return "", err
}
return doc.Find(".livelbl a").Text(), nil
}