Skip to content

Commit

Permalink
获取抢购连接后只访问一次设置cookie即可 不需要重复访问 加快速度
Browse files Browse the repository at this point in the history
  • Loading branch information
zqjzqj committed Jan 8, 2021
1 parent fb4fbeb commit d10f314
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions secKill/jdSecKill.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,8 @@ func (jsk *jdSecKill) Run() error {
for _, v := range jsk.bWorksCtx {
go func(ctx2 context.Context) {
jsk.FetchSecKillUrl()
logs.PrintlnInfo("正在访问抢购连接......")
_, _, _, _ = page.Navigate(jsk.SecKillUrl).WithReferrer("https://item.jd.com/"+jsk.SkuId+".html").Do(ctx2)
SecKillRE:
//请求抢购连接,提交订单
err := jsk.ReqSubmitSecKillOrder(ctx2)
Expand Down Expand Up @@ -348,8 +350,6 @@ func (jsk *jdSecKill) ReqSubmitSecKillOrder(ctx context.Context) error {
ctx = jsk.bCtx
}
//这里直接使用浏览器跳转 主要目的是获取cookie
logs.PrintlnInfo("正在访问抢购连接......")
_, _, _, _ = page.Navigate(jsk.SecKillUrl).WithReferrer("https://item.jd.com/"+jsk.SkuId+".html").Do(ctx)
skUrl := fmt.Sprintf("https://marathon.jd.com/seckill/seckill.action?=skuId=%s&num=%d&rid=%d", jsk.SkuId, jsk.SecKillNum, time.Now().Unix())
logs.PrintlnInfo("访问抢购订单结算页面......", skUrl)
_, _, _, _ = page.Navigate(skUrl).WithReferrer("https://item.jd.com/"+jsk.SkuId+".html").Do(ctx)
Expand Down

0 comments on commit d10f314

Please sign in to comment.