You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
import re |
|
|
from playwright.sync_api import Playwright, sync_playwright, expect |
|
|
import time |
|
|
from get_jd_timestamp import jd_timer |
|
|
|
|
|
target: str = '2025-01-21 15:41:00' |
|
|
|
|
|
target_timestamp = int(time.mktime(time.strptime(target, '%Y-%m-%d %H:%M:%S'))*1000) |
|
|
AC_URL = f"https://h5static.m.jd.com/mall/active/xXzWGzxuJ6HRksjXms2x3cQsh25/index.html?utm_term=Wxfriends&utm_user=plusmember&utm_source=iosapp&utm_campaign=t_335139774&utm_medium=appshare&_ts={str(target_timestamp)}&ad_od=share&gxd=RnAowmYKPGXfnp4Sq4B_W578vOMp4E7JgUugKDcomXTOIlSPI-BCnvuytD0G7kc&gx=RnAomDgLPTTeyp5Z_sA9" |
|
|
|
|
|
def run(playwright: Playwright) -> None: |
|
|
|
|
|
browser = playwright.chromium.launch(headless=False) |
|
|
context = browser.new_context() |
|
|
page = context.new_page() |
|
|
page.goto("https://www.jd.com/") |
|
|
page.get_by_role("link", name="你好,请登录").click() |
|
|
page.get_by_placeholder("账号名/手机号/邮箱").click() |
|
|
page.get_by_placeholder("账号名/手机号/邮箱").fill("18611659484") |
|
|
page.get_by_placeholder("密码").fill("Rog129Sunx1532") |
|
|
page.get_by_role("link", name="登 录").click() |
|
|
|
|
|
time.sleep(30) |
|
|
|
|
|
if page.get_by_text("hehedehehe"): |
|
|
# 打开活动页面 |
|
|
print('登录成功!') |
|
|
print(AC_URL) |
|
|
page2 = context.new_page() |
|
|
page2.goto(AC_URL) |
|
|
# 倒计时 |
|
|
jd_timer(target) |
|
|
# 点击领取 |
|
|
page2.click(".coupon_wrapper") |
|
|
target_name = target.replace(':', '-').replace(' ', '_') |
|
|
page2.screenshot(path=f"{target_name}.png") |
|
|
print('点击立即领取!') |
|
|
time.sleep(100) |
|
|
|
|
|
# --------------------- |
|
|
context.close() |
|
|
browser.close() |
|
|
|
|
|
|
|
|
with sync_playwright() as playwright: |
|
|
run(playwright)
|
|
|
|