From 48dac396b3909b132c802f82e406447ee824fe69 Mon Sep 17 00:00:00 2001 From: ztino <> Date: Mon, 4 Jan 2021 19:38:51 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=8F=AF=E8=83=BD=E5=BC=95?= =?UTF-8?q?=E8=B5=B7=E6=8A=A2=E8=B4=AD=E9=93=BE=E6=8E=A5=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jd_seckill/seckill.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/jd_seckill/seckill.go b/jd_seckill/seckill.go index 32f62dd..e493eff 100644 --- a/jd_seckill/seckill.go +++ b/jd_seckill/seckill.go @@ -73,9 +73,12 @@ func (this *Seckill) getSeckillUrl() (string, error) { req.SetHeader("User-Agent", this.getUserAgent()) req.SetHeader("Host", "itemko.jd.com") req.SetHeader("Referer", fmt.Sprintf("https://item.jd.com/%s.html", skuId)) + req.SetUrl("https://itemko.jd.com/itemShowBtn?callback=jQuery" + strconv.Itoa(common.Rand(1000000, 9999999)) + "&skuId=" + skuId + "&from=pc&_=" + strconv.Itoa(int(time.Now().Unix()*1000))).SetMethod("get") url := "" for { - _, body, _ := req.SetUrl("https://itemko.jd.com/itemShowBtn?callback=jQuery{}" + strconv.Itoa(common.Rand(1000000, 9999999)) + "&skuId=" + skuId + "&from=pc&_=" + strconv.Itoa(int(time.Now().Unix()*1000))).SetMethod("get").Send().End() + _, body, _ := req.Send().End() + //临时打印数据 + log.Println("返回信息:"+body) var cbBody string cbBody = body spBody := strings.Split(body, "(") @@ -90,6 +93,7 @@ func (this *Seckill) getSeckillUrl() (string, error) { log.Println("抢购链接获取失败,稍后自动重试") time.Sleep(300 * time.Millisecond) } + url = "https:"+url //https://divide.jd.com/user_routing?skuId=8654289&sn=c3f4ececd8461f0e4d7267e96a91e0e0&from=pc url = strings.ReplaceAll(url, "divide", "marathon") //https://marathon.jd.com/captcha.html?skuId=8654289&sn=c3f4ececd8461f0e4d7267e96a91e0e0&from=pc @@ -110,6 +114,7 @@ func (this *Seckill) RequestSeckillUrl() { } url, _ := this.getSeckillUrl() skuId := this.conf.MustValue("config", "sku_id", "") + log.Println("访问商品的抢购连接...") req := httpc.NewRequest(this.client) req.SetHeader("User-Agent", this.getUserAgent()) req.SetHeader("Host", "marathon.jd.com")