python snapping software and plug in and script with complete source code
- 2021-09-16 07:33:25
- OfStack
It has been 5 months since the last article about Taobao snapping up the source code. In the past 5 months, I have mastered the deeper snapping technology and principle through continuous study. In the last article, I only shared the snapping up source code about the goods added to the shopping cart, and there are some deficiencies.
Bloggers do not provide any server-side programs, nor do they provide any software for snapping up fees. This article is only used as a sample code for learning selenium framework and GUI development. This idea can be applied to any other website, such as JD.COM, Tmall and Taobao. It does not belong to plug-ins or software, but only belongs to an automated click tool. If the legitimate rights and interests of any company are infringed, please contact by private message, and the relevant codes will be deleted in the first time.
In this article, I will attach the complete source code, its graphical development source code and encryption source code. The code is slightly longer. If you have any doubts, you can contact the blogger by private message in the station.
#!/usr/bin/python
# -*- coding: UTF-8 -*-
#made in white-night
#coding=utf-8
import re
from PyQt5.QtWidgets import *
import sys
from PyQt5 import QtCore, QtWidgets
from selenium import webdriver
import datetime
import time
import threading
import wmi
class LoginDlg(QDialog):
def __init__(self, parent=None):
super(LoginDlg, self).__init__(parent)
usr = QLabel(" Please select the snapping method: ")
pwd = QLabel(" Please enter the snap-up time: ")
self.lineEdit = QLineEdit("",self)
self.lb0 = QLabel(" Please enter the website to be snapped up: ", self)
self.lbl = QLabel(" Waiting to choose the snapping plan ", self)
self.lb2 = QLabel(" Machine code: ", self)
self.lb3 = QLabel(" Authorization code: ", self)
self.lb4 = QLabel(" (Please add a group to obtain authorization: 462510942 ) ", self)
self.lb5 = QLabel(" (Do not change the machine code, otherwise you cannot authorize) ", self)
self.lineEdit2 = QLineEdit("", self)
self.lineEdit1 = QLineEdit("", self)
self.combo = QComboBox(self)
self.combo.addItem("0 Please select the snap-up plan ")
self.combo.addItem("1 Add shopping cart ")
self.combo.addItem("2 No shopping cart ")
self.combo.addItem("3 , snap up coupons ")
# self.lineEdit.move(200,100)
self.lb0.move(50, 100)
self.lbl.move(50, 150)
self.lb2.move(50, 200)
self.lb3.move(50, 250)
self.lb4.move(250, 250)
self.lb5.move(250, 200)
self.lineEdit2.move(100, 200)
self.lineEdit1.move(100, 250)
self.setGeometry(300, 300, 300, 200)
self.setWindowTitle('QComboBox')
self.show()
self.dateTimeEdit = QtWidgets.QDateTimeEdit()
self.dateTimeEdit.setGeometry(QtCore.QRect(140, 50, 121, 22))
self.dateTimeEdit.setDateTime(QtCore.QDateTime(QtCore.QDate(2018, 11, 1), QtCore.QTime(9, 0, 0)))
self.dateTimeEdit.setObjectName("dateTimeEdit")
gridLayout = QGridLayout()
gridLayout.addWidget(usr, 0, 0, 1, 1)
gridLayout.addWidget(pwd, 1, 0, 1, 1)
gridLayout.addWidget(self.lb0, 2, 0, 1, 1)
gridLayout.addWidget(self.combo, 0, 1, 1, 3)
gridLayout.addWidget(self.dateTimeEdit, 1, 1, 1, 3)
gridLayout.addWidget(self.lineEdit, 2, 1, 1, 3)
sqBtn = QPushButton(" Authorization ")
okBtn = QPushButton(" Determine ")
cancelBtn = QPushButton(" Shut down the software ")
btnLayout = QHBoxLayout()
btnLayout.setSpacing(60)
btnLayout.addWidget(okBtn)
btnLayout.addWidget(cancelBtn)
btnLayout.addWidget(sqBtn)
dlgLayout = QVBoxLayout()
dlgLayout.setContentsMargins(40, 40, 40, 40)
dlgLayout.addLayout(gridLayout)
dlgLayout.addStretch(40)
dlgLayout.addLayout(btnLayout)
self.setLayout(dlgLayout)
okBtn.clicked.connect(self.accept)
cancelBtn.clicked.connect(self.reject)
sqBtn.clicked.connect(self.cpuid)
self.setWindowTitle("VN Assist in snapping up software ")
self.resize(600, 400)
self.thread_handle = None
def thread_function(self,index):
# Need to add a thread 1 Judgment of global variables Used to terminate an infinite loop Used to switch schemes
data = self.cpuid1[2] + self.cpuid1[5] + min(self.cpuid1) + self.cpuid1[-5] + self.cpuid1[1] + self.cpuid1[3] + self.cpuid1[4] + max(self.cpuid1) + self.cpuid1[1] + \
self.cpuid1[-1] + self.cpuid1[-3] + "V" + "N" + self.cpuid1[-2] + self.cpuid1[0] + self.cpuid1[-4]
if self.lineEdit1.text() == data and self.lineEdit2.text() == self.cpuid1:
if index==0:
self.lbl.setText(" Please select the snap-up plan, and then click OK ")
elif index==1:
self.lbl.setText(" Successfully invoked the shopping cart scheme ")
self.gouwubuy()
elif index==2:
self.lbl.setText(" Successful call to no shopping cart scheme ")
self.buy()
else:
self.lbl.setText(" Successfully called the coupon grabbing scheme ")
self.quanbuy()
else:
self.lbl.setText(" Please enter the correct authorization code ")
def accept(self):
# Thread creation
self.thread_handle = threading.Thread(target=LoginDlg.thread_function,args=(self,self.combo.currentIndex()))
self.thread_handle.start()
return
def gouwubuy(self):
browser.get("https://cart.taobao.com/cart.htm")
# Click the Select All button in the shopping cart
buyt = self.dateTimeEdit.text()
buyti = re.findall(" (.*)",buyt)
buytime = buyti[0]+":00.000000"
while True:
now = datetime.datetime.now().strftime('%H:%M:%S.%f')
# Compare the time. If the time comes, click Settlement
if now > buytime:
# Click the settlement button
try:
if browser.find_element_by_id("J_Go"):
browser.find_element_by_id("J_Go").click()
except:
pass
try:
if browser.find_element_by_link_text(' Submit an order '):
browser.find_element_by_link_text(' Submit an order ').click()
now1 = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f')
self.lbl.setText(" The order submission time is: %s"% now1)
except:
pass
def buy(self):
browser.get(self.lineEdit.text())
while True:
try:
if browser.find_element_by_link_text(' Buy now '):
browser.find_element_by_link_text(' Buy now ').click()
except:
pass
try:
if browser.find_element_by_link_text(' Submit an order '):
browser.find_element_by_link_text(' Submit an order ').click()
now1 = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f')
self.lbl.setText(" The order submission time is: %s" % now1)
break
except:
pass
def quanbuy(self):
browser.get(self.lineEdit.text())
while True:
now = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f')
# Compare the time. If the time comes, click Settlement
try:
if browser.find_element_by_link_text(' Rob at once '):
browser.find_element_by_link_text(' Rob at once ').click()
except:
pass
try:
if browser.find_element_by_link_text(' Click to collect coupons '):
browser.find_element_by_link_text(' Click to collect coupons ').click()
except:
pass
def cpuid(self):
w = wmi.WMI()
cpus = w.Win32_Processor()
for u in cpus:
self.cpuid1 = u.ProcessorId
self.lineEdit2.setText(self.cpuid1)
def login():
# Open the Taobao login page and scan the code to log in
browser.get("https://www.taobao.com")
time.sleep(3)
if browser.find_element_by_link_text(" Dear, please log in "):
browser.find_element_by_link_text(" Dear, please log in ").click()
time.sleep(3)
if __name__ == '__main__':
browser = webdriver.Chrome()
browser.maximize_window()
login()
app = QApplication(sys.argv)
dlg = LoginDlg()
dlg.show()
dlg.exec_()
app.exit()