expose Get methods

This commit is contained in:
milarin 2023-03-03 15:10:00 +01:00
parent e542fa0c97
commit e8cd6ab8c5

View File

@ -11,7 +11,7 @@ import (
"github.com/PuerkitoBio/goquery" "github.com/PuerkitoBio/goquery"
) )
func (api *Api) getWithCookie(ctx context.Context, url string) (*goquery.Document, error) { func (api *Api) GetWithCookie(ctx context.Context, url string) (*goquery.Document, error) {
if api.Cookie == "" { if api.Cookie == "" {
return nil, errors.New("no API cookie set") return nil, errors.New("no API cookie set")
} }
@ -36,7 +36,7 @@ func (api *Api) getWithCookie(ctx context.Context, url string) (*goquery.Documen
return goquery.NewDocumentFromReader(r) return goquery.NewDocumentFromReader(r)
} }
func (api *Api) get(ctx context.Context, url string) (*goquery.Document, error) { func (api *Api) Get(ctx context.Context, url string) (*goquery.Document, error) {
curl := exec.CommandContext(ctx, "curl", curl := exec.CommandContext(ctx, "curl",
"-s", url, "-s", url,
"-H", fmt.Sprintf("User-Agent: %s", api.UserAgent), "-H", fmt.Sprintf("User-Agent: %s", api.UserAgent),