-
Notifications
You must be signed in to change notification settings - Fork 13
/
TaoBao.py
77 lines (72 loc) · 3.38 KB
/
TaoBao.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# -*- coding=UTF-8 -*-
from selenium import webdriver
import time
import datetime
from tkinter import *
import threading
import tkinter.messagebox
def make_app():
app = Tk()
app.geometry('300x250')
Label().pack()
Label(text='请务必按照格式输入抢单时间').pack()
Label(text='2018-10-30 20:44:26.463135').pack()
Entry(name='ipt').pack()
Label(text='请输入买家备注(如不填写可提高抢单速度)').pack()
Entry(name='ipt2').pack()
Label(name='lb1', text='抢单中').pack()
Button(text='点击开始抢单', command=login).pack()
return app
def login():
# driver = webdriver.Chrome(executable_path='./chromedriver.exe')
th = threading.Thread(target=sign_up)
th.start()
def sign_up():
driver = webdriver.Chrome()
driver.get('https://www.taobao.com/')
time.sleep(3)
if driver.find_element_by_link_text('亲,请登录'):
driver.find_element_by_link_text('亲,请登录').click()
tkinter.messagebox.showinfo('提示', '请在15秒内完成登录二维码扫描')
time.sleep(15)
driver.get("https://cart.taobao.com/cart.htm")
while tkinter.messagebox.askokcancel('提示', '请选择抢购的商品。打勾后点击确定') == False:
tkinter.messagebox.askokcancel('提示', '请选择抢购的商品。打勾后点击确定')
tkinter.messagebox.showinfo('提示', '请勿关闭网页')
if app.children['ipt2'].get() == '':
while True:
now = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f')
if now >= app.children['ipt'].get():
try:
if app.children['lb1']['text'] == '抢单中':
if driver.find_element_by_id('J_Go'):
driver.find_element_by_id('J_Go').click()
app.children['lb1']['text'] = '商品上线'
if app.children['lb1']['text'] != '抢单中':
driver.find_element_by_link_text('提交订单').click()
tkinter.messagebox.showinfo('提示', '抢单成功')
except:
time.sleep(0.001)
time.sleep(0.001)
else:
while True:
now = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f')
if now >= app.children['ipt'].get():
try:
if app.children['lb1']['text'] == '抢单中':
if driver.find_element_by_id('J_Go'):
driver.find_element_by_id('J_Go').click()
app.children['lb1']['text'] = '商品上线'
if app.children['lb1']['text'] != '抢单中':
input_text = driver.find_elements_by_tag_name('textarea')[0]
if input_text:
text = app.children['ipt2'].get()
input_text.send_keys(text)
driver.find_element_by_link_text('提交订单').click()
tkinter.messagebox.showinfo('提示', '抢单成功')
except:
time.sleep(0.001)
time.sleep(0.001)
if __name__ == '__main__':
app = make_app()
app.mainloop()