Add support for APIs (in addition to scraping)

This commit is contained in:
2026-01-04 15:36:56 -05:00
parent 8a63e50228
commit 8672aadcb8
6 changed files with 119 additions and 66 deletions
+23
View File
@@ -0,0 +1,23 @@
package websrc
import (
"encoding/json"
"errors"
)
func GetByScrape(flareSolverrEndpoint, webPageURL string, loadSeconds float32) (string, error) {
payload, err := json.Marshal(payloadFlareSolverrT{
Cmd: "request.get",
URL: webPageURL,
MaxTimeoutMilliseconds: 60000,
WaitInSeconds: loadSeconds,
})
if err != nil {
return "", errors.New("unable to marshal FlareSolverr payload to JSON: " + err.Error())
}
body, err := GetByAPIJson("POST", flareSolverrEndpoint, payload)
if err != nil {
return "", err
}
return string(body), nil
}