collect optimize

This commit is contained in:
mubai
2026-04-01 00:21:29 +08:00
parent 8a6bc33cad
commit 8243d2171f
47 changed files with 2774 additions and 1770 deletions

View File

@@ -2,14 +2,15 @@ package util
import (
"fmt"
"github.com/gocolly/colly/v2"
"github.com/gocolly/colly/v2/extensions"
"log"
"net/http"
"net/url"
"strconv"
"strings"
"time"
"github.com/gocolly/colly/v2"
"github.com/gocolly/colly/v2/extensions"
)
/*
@@ -29,6 +30,18 @@ type RequestInfo struct {
Err string `json:"err"` // 错误信息
}
// CopyRequestInfo 属性复制, 隔离地址引用造成的并发问题
func CopyRequestInfo(r RequestInfo) RequestInfo {
// 初始化返回值
newInfo := RequestInfo{Uri: r.Uri, Params: url.Values{}}
// 循环拷贝r的每个k,v
for k, v := range r.Params {
newInfo.Params[k] = append([]string(nil), v...)
}
return newInfo
}
// RefererUrl 记录上次请求的url
var RefererUrl string