Python寫一個京東搶券腳本


最近看到京東圖書每天有優惠券發放,滿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)

測試發現對請求的頻率沒有限制,太棒了。
然並卵,還是沒搶到,嚴重懷疑他丫的活動是假的。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM