pcgamedb/utils/keeplinks.go

23 lines
461 B
Go

package utils
import (
"bytes"
"fmt"
"strings"
"github.com/PuerkitoBio/goquery"
)
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)
if err != nil {
return "", err
}
doc, err := goquery.NewDocumentFromReader(bytes.NewReader(resp.Body()))
if err != nil {
return "", err
}
return doc.Find(".livelbl a").Text(), nil
}