欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

python實現(xiàn)京東秒殺功能

 更新時間:2018年07月30日 14:51:31   作者:Erick-LONG  
這篇文章主要為大家詳細介紹了python實現(xiàn)京東秒殺功能,具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實例為大家分享了python實現(xiàn)京東秒殺的具體代碼,供大家參考,具體內(nèi)容如下

# _*_coding:utf-8_*_ 
from selenium import webdriver
import datetime 
import time


driver = webdriver.Chrome(executable_path='chromedriver.exe')

def login(uname, pwd):
 driver.get("http://www.jd.com")
 driver.find_element_by_link_text("你好,請登錄").click()

 driver.find_element_by_link_text("賬戶登錄").click()
 driver.find_element_by_name("loginname").send_keys(uname)
 driver.find_element_by_name("nloginpwd").send_keys(pwd)
 driver.find_element_by_id("loginsubmit").click()

 driver.get("https://cart.jd.com/cart.action")

 driver.find_element_by_link_text("去結(jié)算").click()
 now = datetime.datetime.now()
 print('login success:',now.strftime('%Y-%m-%d %H:%M:%S'))


# buytime = '2016-12-27 22:31:00' 
def buy_on_time(buytime):
 while True:
  now = datetime.datetime.now()
  if now.strftime('%Y-%m-%d %H:%M:%S') == buytime:
   while True:
    try:
     driver.find_element_by_id('order-submit').click()
    except Exception as e:
     time.sleep(0.1)
   print ('purchase success',now.strftime('%Y-%m-%d %H:%M:%S'))
   time.sleep(0.5)


# entrance
login('username', 'password')
buy_on_time('2017-01-01 14:00:01')

以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論