最近看到京东图书每天有优惠券发放,满200减100,诱惑还是蛮大的。反正自己抢不到,想着写个脚本试试。
几个关键步骤
获取优惠券的url
直接审查元素获取cookie
通过本地代理,比如BurpSuite定时调用
# coding=utf-8
import requests, schedule, time
def do_request(_url, _cookie):
countdown = 10
while countdown > 0:
r = requests.get(_url, cookies=_cookie)
countdown = countdown - 1
print(countdown)
resp = r.text
print(resp)
cookie_str = '''__jda=1222706...=%u5317%u4EAC'''
lists = cookie_str.split(';')
_cookie = {}
for i in lists:
j = i.strip()
j = j.split('=')
_cookie[j[0]] = j[1]
_url = "https://coupon.jd.com/ilink/couponSendFront/send_index.action?key=8fb2357aa1dc4c6eaa3f7d7464f1afc8&roleId=11422466&to=https://readinglife.jd.com/"
def job():
print("I'm working...")
print(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time())))
# do_request(_url, _cookie)
# schedule.every().minutes.do(job)
#实际操作可以提前一分钟,并且延长countdown
schedule.every().day.at("10:00").do(job)
while True:
schedule.run_pending()
time.sleep(1)
测试发现对请求的频率没有限制,太棒了。
然并卵,还是没抢到,严重怀疑他丫的活动是假的。