SoFunction
Updated on 2024-11-13

Python implementation of the Jingdong spike function code

In this article, we share the example of Python to achieve the Jingdong spike function of the specific code for your reference, the specific content is as follows

#Python 3.5

#coding:utf-8
#import scrapy
from selenium import webdriver
import time
import datetime
driver = ()
('https:/')
class JDLOGIN(object):
  def login_jd(self,num,pwd):
    driver.find_element_by_link_text('Hello, please log in').click()
    (10)
    driver.find_element_by_link_text('Account Login').click()
    (3)
    driver.find_element_by_id('loginname').send_keys(num)
    driver.find_element_by_id('nloginpwd').send_keys(pwd)
    (3)
    driver.find_element_by_id('loginsubmit').click()
    (5)
    nowwhandle = driver.current_window_handle
    driver.find_element_by_link_text('My Cart').click()
    allhandles = driver.window_handles
    for handle in allhandles:
      if handle != nowwhandle:
        driver.switch_to_window(handle)# Switch to window Shopping cart page
    (5)
    driver.find_element_by_link_text('Going to settlement').click()
    (4)
  def buy_on_time(self,buytime):
    while True:
      now = ()
      if ('%Y-%m-%d %H:%M:%S') == buytime:
        driver.find_element_by_id('order-submit').click()
        (3)
        print(('%Y-%m-%d %H:%M:%S'))
        print('successful!!!')
      (0.5)
      # Return to the original window
      #driver.switch_to_window(nowwhandle)
  def start(self,num,pwd,buytime):
    self.login_jd(num,pwd)
    self.buy_on_time(buytime)
jdlogin=JDLOGIN()
('Cell phone number','Password','Seconds to kill time' )

You need to first add the spike items to the shopping cart (must be a spike item, no need to check the [checkbox] when you checkout after adding a spike item to the shopping cart), and set the default shipping address in advance

The code was written in idle time, without further optimization, and the object-oriented functions are not streamlined enough, but the function has been implemented

You need to install the selenium package from the cmd command line: pip install selenium

The rest of the packages are the same, download what you need

The above is a small introduction to the Python implementation of Jingdong spike function detailed integration, I hope to help you, if you have any questions please leave me a message, I will reply to you in a timely manner. I would also like to thank you very much for your support of my website!