Skip to content

Instantly share code, notes, and snippets.

@a9QrX3Lu
Last active October 3, 2021 12:53
Show Gist options
  • Select an option

  • Save a9QrX3Lu/d3d3adddb96833a240032867d32b9820 to your computer and use it in GitHub Desktop.

Select an option

Save a9QrX3Lu/d3d3adddb96833a240032867d32b9820 to your computer and use it in GitHub Desktop.
Auto buying script for jd
#!/usr/bin/python3
#coding:utf-8
import time
from selenium import webdriver
# enter username and password below
jd_up={"ue":"***","pd":"***"}
chrome=webdriver.Chrome()
chrome.get(url="https://passport.jd.com/new/login.aspx?")
chrome.find_element_by_xpath("//*[@id=\"content\"]/div/div[1]/div/div[3]/a").click()
User=chrome.find_element_by_id("loginname")
User.clear()
User.send_keys(jd_up["ue"])
Passwd=chrome.find_element_by_id("nloginpwd")
Passwd.clear()
Passwd.send_keys(jd_up["pd"])
chrome.find_element_by_id("loginsubmit").click()
# Manually complete the validation step
time.sleep(10)
while True:
try:
chrome.get(url="https://item.jd.com/100015285144.html")
chrome.find_element_by_id("choose-btn-ko").click()
chrome.find_element_by_id("order-submit").click()
print("抢购成功并且已下单!!")
chrome.quit()
except Exception:
print("还未开始抢购!!")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment