tychxn / jd-assistant

京东抢购助手:包含登录,查询商品库存/价格,添加/清空购物车,抢购商品(下单),查询订单等功能
MIT License
5.18k stars 1.92k forks source link

抢购链接获取失败,%s不是抢购商品或抢购页面暂未刷新,0.1秒后重试 #186

Open DaBaiiiii opened 3 years ago

DaBaiiiii commented 3 years ago
while True:
            resp = self.sess.get(url=url, headers=headers, params=payload)
            resp_json = parse_json(resp.text)
            print('resp_json', resp_json)
            if resp_json.get('url'):
                # https://divide.jd.com/user_routing?skuId=8654289&sn=c3f4ececd8461f0e4d7267e96a91e0e0&from=pc
                router_url = 'https:' + resp_json.get('url')
                # https://marathon.jd.com/captcha.html?skuId=8654289&sn=c3f4ececd8461f0e4d7267e96a91e0e0&from=pc
                seckill_url = router_url.replace('divide', 'marathon').replace('user_routing', 'captcha.html')
                logger.info("抢购链接获取成功: %s", seckill_url)
                return seckill_url
            else:
                logger.info("抢购链接获取失败,%s不是抢购商品或抢购页面暂未刷新,0.1秒后重试", sku_id)
                time.sleep(0.1)

self.sess.get(url=url, headers=headers, params=payload)返回url为‘’(空字符串)