淘宝秒杀
from selenium import webdriver
from time import sleep
import datetime
#打开一个谷歌浏览器,并且开始与浏览器会话
dr = webdriver.Chrome(executable_path="/Users/qiangsu/Downloads/chromedriver")
def login():
#打开淘宝
dr.get("http://www.taobao.com")
dr.find_element_by_link_text("亲,请登录").click()
dr.find_element_by_class_name("icon-qrcode").click();
#扫描二维码登陆
sleep(10)
now = datetime.datetime.now()
print('login success:', now.strftime('%Y-%m-%d %H:%M:%S'))
def buy(buytime):
flag =True
while flag:
now = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f')
# 对比时间,时间到的话就点击结算
if now > buytime:
flag = True
while flag:
try:
dr.get("https://chaoshi.detail.tmall.com/item.htm?spm=a1z0d.6639537.1997196601.169.106c7484bsf0w1&id=20739895092")
dr.find_element_b