Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
e2ef035c39
|
|||
|
c29f039aaf
|
@@ -3,6 +3,7 @@ package flaresolverr
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -164,7 +165,7 @@ func (f *Flaresolverr) DetermineProfile(userAgent string) profiles.ClientProfile
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Flaresolverr) SimulateGet(url string, ua string, cookies []*http.Cookie, opts ...tls_client.HttpClientOption) (*fhttp.Response, error) {
|
func (f *Flaresolverr) simulateRequest(method string, url string, ua string, cookies []*http.Cookie, body io.Reader, opts ...tls_client.HttpClientOption) (*fhttp.Response, error) {
|
||||||
currentUA := ua
|
currentUA := ua
|
||||||
currentCookies := cookies
|
currentCookies := cookies
|
||||||
|
|
||||||
@@ -189,7 +190,7 @@ func (f *Flaresolverr) SimulateGet(url string, ua string, cookies []*http.Cookie
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to create client: %w", err)
|
return nil, fmt.Errorf("failed to create client: %w", err)
|
||||||
}
|
}
|
||||||
req, err := fhttp.NewRequest(http.MethodGet, url, nil)
|
req, err := fhttp.NewRequest(method, url, body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to create request: %w", err)
|
return nil, fmt.Errorf("failed to create request: %w", err)
|
||||||
}
|
}
|
||||||
@@ -252,3 +253,11 @@ func (f *Flaresolverr) SimulateGet(url string, ua string, cookies []*http.Cookie
|
|||||||
|
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (f *Flaresolverr) SimulateGet(url string, ua string, cookies []*http.Cookie, opts ...tls_client.HttpClientOption) (*fhttp.Response, error) {
|
||||||
|
return f.simulateRequest("GET", url, ua, cookies, nil, opts...)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *Flaresolverr) SimulatePost(url string, ua string, cookies []*http.Cookie, body io.Reader, opts ...tls_client.HttpClientOption) (*fhttp.Response, error) {
|
||||||
|
return f.simulateRequest("POST", url, ua, cookies, body, opts...)
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user