collect optimization

This commit is contained in:
mubai
2026-03-30 21:47:26 +08:00
parent 0d258e90bd
commit 8a6bc33cad
23 changed files with 827 additions and 354 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