|
@@ -70,7 +70,10 @@ func getCodeByFree(path, stype, head, cookie string) (code string, respheader ht
|
|
|
defer util.Catch()
|
|
|
client := req.C().
|
|
|
SetTimeout(spiderutil.Config.TimeOut * time.Second).
|
|
|
- SetTLSClientConfig(&tls.Config{InsecureSkipVerify: true}) //忽略证书验证
|
|
|
+ SetTLSClientConfig(&tls.Config{
|
|
|
+ Renegotiation: tls.RenegotiateOnceAsClient,
|
|
|
+ InsecureSkipVerify: true,
|
|
|
+ }) //忽略证书验证
|
|
|
headers := map[string]string{}
|
|
|
if head != "" {
|
|
|
json.Unmarshal([]byte(head), &headers)
|
|
@@ -79,7 +82,12 @@ func getCodeByFree(path, stype, head, cookie string) (code string, respheader ht
|
|
|
if cookie != "" {
|
|
|
json.Unmarshal([]byte(cookie), &cookies)
|
|
|
}
|
|
|
- for times := 1; times <= 3; times++ { //重试三次
|
|
|
+ for times := 1; times <= 6; times++ { //重试三次
|
|
|
+ if times > 4 { //重试第4次开始,使用代理ip
|
|
|
+ proxyIp := spiderutil.GetProxyAddr(spiderutil.Config.ProxyAddr, spiderutil.Config.ProxyAuthor) //获取代理地址
|
|
|
+ util.Debug("proxy:", proxyIp)
|
|
|
+ client.SetProxyURL(proxyIp) //设置代理IP
|
|
|
+ }
|
|
|
request := client.R()
|
|
|
if len(headers) > 0 {
|
|
|
request.SetHeaders(headers)
|
|
@@ -129,7 +137,10 @@ func getCodeByPay(path, stype, head, cookie string) (code string, respheader htt
|
|
|
defer util.Catch()
|
|
|
client := req.C().
|
|
|
SetTimeout(spiderutil.Config.TimeOut * time.Second).
|
|
|
- SetTLSClientConfig(&tls.Config{InsecureSkipVerify: true}) //忽略证书验证
|
|
|
+ SetTLSClientConfig(&tls.Config{
|
|
|
+ Renegotiation: tls.RenegotiateOnceAsClient,
|
|
|
+ InsecureSkipVerify: true,
|
|
|
+ }) //忽略证书验证
|
|
|
headers := map[string]string{}
|
|
|
if head != "" {
|
|
|
json.Unmarshal([]byte(head), &headers)
|
|
@@ -138,7 +149,12 @@ func getCodeByPay(path, stype, head, cookie string) (code string, respheader htt
|
|
|
if cookie != "" {
|
|
|
json.Unmarshal([]byte(cookie), &cookies)
|
|
|
}
|
|
|
- for times := 1; times <= 3; times++ { //重试三次
|
|
|
+ for times := 1; times <= 6; times++ { //重试三次
|
|
|
+ if times > 4 { //重试第4次开始,使用代理ip
|
|
|
+ proxyIp := spiderutil.GetProxyAddr(spiderutil.Config.ProxyAddr, spiderutil.Config.ProxyAuthor) //获取代理地址
|
|
|
+ util.Debug("proxy:", proxyIp)
|
|
|
+ client.SetProxyURL(proxyIp) //设置代理IP
|
|
|
+ }
|
|
|
request := client.R()
|
|
|
if len(headers) > 0 {
|
|
|
request.SetHeaders(headers)
|