feat!: migrate simulate requests to resty v3 and add instance options

This commit is contained in:
2026-06-13 15:54:21 +10:00
parent e2ef035c39
commit c14db529f0
5 changed files with 123 additions and 203 deletions
+40 -11
View File
@@ -1,19 +1,21 @@
package test
import (
"io"
"testing"
"git.nite07.com/nite/go-flaresolverr"
)
func TestGetV1(t *testing.T) {
f, err := flaresolverr.GetInstance("http://10.10.10.1:8191", "", "socks5://10.10.10.1:7900")
f, err := flaresolverr.GetInstance(
"http://10.10.10.1:8191",
flaresolverr.WithProxy("socks5://10.10.10.1:7900"),
)
if err != nil {
t.Error(err)
return
}
resp, err := f.GetV1("https://x1337x.cc/", nil)
resp, err := f.GetV1("https://steamrip.com/games-list-page/", nil)
if err != nil {
t.Error(err)
return
@@ -22,19 +24,46 @@ func TestGetV1(t *testing.T) {
t.Error("status code != 200", resp.Solution.Status)
return
}
resp2, err := f.SimulateGet("https://x1337x.cc/user/FitGirl/", resp.Solution.UserAgent, resp.Solution.Cookies)
resp2, err := f.SimulateGet("https://steamrip.com/games-list-page/", resp.Solution.UserAgent, resp.Solution.Cookies)
if err != nil {
t.Error(err)
return
}
if resp2.StatusCode != 200 {
t.Error("status code != 200", resp2.StatusCode)
return
}
body, err := io.ReadAll(resp2.Body)
if err != nil {
t.Error(err)
if resp2.StatusCode() != 200 {
t.Error("status code != 200", resp2.StatusCode())
return
}
body := resp2.Bytes()
t.Log(string(body))
}
func TestGetV1_2(t *testing.T) {
f, err := flaresolverr.GetInstance(
"http://10.10.10.1:8191",
flaresolverr.WithProxy("socks5://10.10.10.1:7900"),
)
if err != nil {
t.Error(err)
return
}
resp, err := f.GetV1("https://1337x.to", nil)
if err != nil {
t.Error(err)
return
}
if resp.Solution.Status != 200 {
t.Error("status code != 200", resp.Solution.Status)
return
}
resp2, err := f.SimulateGet("https://1337x.to/user/FitGirl/", resp.Solution.UserAgent, resp.Solution.Cookies)
if err != nil {
t.Error(err)
return
}
if resp2.StatusCode() != 200 {
t.Error("status code != 200", resp2.StatusCode())
return
}
body := resp2.Bytes()
t.Log(string(body))
}