mirror of
https://github.com/ProudMuBai/GoFilm.git
synced 2026-05-06 11:49:39 +08:00
collect optimization
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user