fix(card_sender): 优化请求头和加大请求间等待时间
- 添加详细请求头注释,模拟浏览器请求行为 - 使用 resty 库发起请求,设置 origin 和 user-agent 头 - 将请求间随机等待时间从 5-10 秒增加到 20-40 秒 - 保留原有 URL 解析和错误处理逻辑 - 添加请求开始事件追踪,辅助性能监控
This commit is contained in:
@@ -96,16 +96,35 @@ func (s *SendCardTaskTypeFlyFishV2) HandleSendCardTask(ctx context.Context, orde
|
||||
))
|
||||
defer span.End()
|
||||
|
||||
time.Sleep(time.Second * time.Duration(random.RandInt(5, 10)))
|
||||
queryUrl, err := url.Parse(orderItem.PayURL)
|
||||
if err != nil {
|
||||
return errors.New("解析提交地址失败")
|
||||
}
|
||||
|
||||
//accept-language: zh-CN,zh;q=0.9
|
||||
//priority: u=1, i
|
||||
//sec-fetch-site: same-origin
|
||||
//origin: https://ccfy.cardpay.fyi
|
||||
//:scheme: https
|
||||
//accept-encoding: gzip, deflate, br, zstd
|
||||
//sec-fetch-dest: empty
|
||||
//sec-fetch-mode: cors
|
||||
//:authority: ccfy.cardpay.fyi
|
||||
//content-type: application/x-www-form-urlencoded; charset=UTF-8
|
||||
//accept: application/json, text/javascript, */*; q=0.01
|
||||
//x-requested-with: XMLHttpRequest
|
||||
//:method: POST
|
||||
//cookie: PHPSESSID=68991bd61ddf51fd31150fa9bfb27103
|
||||
//user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36
|
||||
//sec-ch-ua-mobile: ?0
|
||||
//content-length: 119
|
||||
//dnt: 1
|
||||
//:path: /submitcard
|
||||
//sec-ch-ua-platform: "macOS"
|
||||
//sec-ch-ua: "Google Chrome";v="143", "Chromium";v="143", "Not A(Brand";v="24"
|
||||
|
||||
// 使用 resty 发起请求
|
||||
webClient := resty.New().
|
||||
SetHeader("accept", "application/json, text/javascript, */*; q=0.01").
|
||||
SetHeader("content-type", "application/x-www-form-urlencoded; charset=UTF-8").
|
||||
SetHeader("origin", "https://ccfy.cardpay.fyi").
|
||||
SetHeader("user-agent", useragent.GetUserAgentByPlatform(useragent.PlatformPhone)).
|
||||
SetTimeout(time.Second * 30).OnBeforeRequest(func(client *resty.Client, request *resty.Request) error {
|
||||
@@ -148,7 +167,7 @@ func (s *SendCardTaskTypeFlyFishV2) HandleSendCardTask(ctx context.Context, orde
|
||||
"productCode": productCode,
|
||||
}
|
||||
|
||||
time.Sleep(time.Second * time.Duration(random.RandInt(5, 10)))
|
||||
time.Sleep(time.Second * time.Duration(random.RandInt(20, 40)))
|
||||
|
||||
span.AddEvent("start submit data")
|
||||
resp, err := webClient.R().SetContext(ctx).SetFormData(formData).Post("https://ccfy.cardpay.fyi/submitcard")
|
||||
|
||||
Reference in New Issue
Block a user