初始化
This commit is contained in:
@ -13,9 +13,9 @@ import (
|
||||
"github.com/chromedp/cdproto/dom"
|
||||
"github.com/chromedp/cdproto/network"
|
||||
"github.com/chromedp/chromedp"
|
||||
"github.com/geziyor/geziyor/internal"
|
||||
"golang.org/x/net/html/charset"
|
||||
"golang.org/x/text/transform"
|
||||
"softdown.com/shusou/geziyor/internal"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -47,7 +47,7 @@ type Options struct {
|
||||
|
||||
// Default values for client
|
||||
const (
|
||||
DefaultUserAgent = "Geziyor 1.0"
|
||||
DefaultUserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36 Edg/128.0.0.0"
|
||||
DefaultMaxBody int64 = 1024 * 1024 * 1024 // 1GB
|
||||
DefaultRetryTimes = 2
|
||||
)
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
"net/url"
|
||||
"sync/atomic"
|
||||
|
||||
"github.com/geziyor/geziyor/internal"
|
||||
"softdown.com/shusou/geziyor/internal"
|
||||
)
|
||||
|
||||
type ProxyURLKey int
|
||||
|
@ -40,15 +40,16 @@ func (r *Request) Cancel() {
|
||||
}
|
||||
|
||||
// NewRequest returns a new Request given a method, URL, and optional body.
|
||||
func NewRequest(method, url string, body io.Reader) (*Request, error) {
|
||||
func NewRequest(method, url, encoding string, body io.Reader) (*Request, error) {
|
||||
req, err := http.NewRequest(method, url, body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
request := Request{
|
||||
Request: req,
|
||||
Meta: make(map[string]interface{}),
|
||||
Request: req,
|
||||
Encoding: encoding,
|
||||
Meta: make(map[string]interface{}),
|
||||
}
|
||||
|
||||
return &request, nil
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
)
|
||||
|
||||
func TestMeta(t *testing.T) {
|
||||
req, err := NewRequest("GET", "https://github.com/geziyor/geziyor", nil)
|
||||
req, err := NewRequest("GET", "https://softdown.com/shusou/geziyor", nil)
|
||||
assert.NoError(t, err)
|
||||
req.Meta["key"] = "value"
|
||||
|
||||
|
Reference in New Issue
Block a user