距上篇關(guān)于淘寶搶購(gòu)源碼的文章已經(jīng)過(guò)去五個(gè)月了,五個(gè)月來(lái)我通過(guò)不停的學(xué)習(xí),掌握了更深層的搶購(gòu)技術(shù)及原理,而上篇文章中我僅分享了關(guān)于加入購(gòu)物車的商品的搶購(gòu)源碼,且有部分不足。
博主不提供任何服務(wù)器端程序,也不提供任何收費(fèi)搶購(gòu)軟件。該文章僅作為學(xué)習(xí)selenium框架及GUI開發(fā)的一個(gè)示例代碼。該思路可運(yùn)用到其他任何網(wǎng)站,京東,天貓,淘寶均可使用,且不屬于外掛或者軟件之類,只屬于一個(gè)自動(dòng)化點(diǎn)擊工具,如有侵犯到任何公司的合法權(quán)益,請(qǐng)私信聯(lián)系,會(huì)第一時(shí)間將相關(guān)代碼給予刪除。
#!/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("請(qǐng)選擇搶購(gòu)方式:")
pwd = QLabel("請(qǐng)輸入搶購(gòu)時(shí)間:")
self.lineEdit = QLineEdit("",self)
self.lb0 = QLabel("請(qǐng)輸入待搶購(gòu)網(wǎng)址:", self)
self.lbl = QLabel("等待選擇搶購(gòu)方案", self)
self.lb2 = QLabel("機(jī)器碼:", self)
self.lb3 = QLabel("授權(quán)碼:", self)
self.lb4 = QLabel("(獲取授權(quán)請(qǐng)加群:462510942)", self)
self.lb5 = QLabel("(請(qǐng)勿更改機(jī)器碼,否則無(wú)法授權(quán))", self)
self.lineEdit2 = QLineEdit("", self)
self.lineEdit1 = QLineEdit("", self)
self.combo = QComboBox(self)
self.combo.addItem("0、請(qǐng)選擇搶購(gòu)方案")
self.combo.addItem("1、加購(gòu)物車")
self.combo.addItem("2、不加購(gòu)物車")
self.combo.addItem("3、搶購(gòu)優(yōu)惠券")
# 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("授權(quán)")
okBtn = QPushButton("確定")
cancelBtn = QPushButton("關(guān)閉軟件")
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輔助搶購(gòu)軟件")
self.resize(600, 400)
self.thread_handle = None
def thread_function(self,index):
# 需要在線程加一個(gè)全局變量的判斷 用于終止死循環(huán) 用來(lái)切換方案
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("請(qǐng)選擇搶購(gòu)方案,然后點(diǎn)擊確定")
elif index==1:
self.lbl.setText("成功調(diào)用加購(gòu)物車方案")
self.gouwubuy()
elif index==2:
self.lbl.setText("成功調(diào)用不加購(gòu)物車方案")
self.buy()
else:
self.lbl.setText("成功調(diào)用搶券方案")
self.quanbuy()
else:
self.lbl.setText("請(qǐng)輸入正確的授權(quán)碼")
def accept(self):
# 線程創(chuàng)建
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")
# 點(diǎn)擊購(gòu)物車?yán)锶x按鈕
buyt = self.dateTimeEdit.text()
buyti = re.findall(" (.*)",buyt)
buytime = buyti[0]+":00.000000"
while True:
now = datetime.datetime.now().strftime('%H:%M:%S.%f')
# 對(duì)比時(shí)間,時(shí)間到的話就點(diǎn)擊結(jié)算
if now > buytime:
# 點(diǎn)擊結(jié)算按鈕
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('提交訂單'):
browser.find_element_by_link_text('提交訂單').click()
now1 = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f')
self.lbl.setText("提交訂單時(shí)間為:%s"% now1)
except:
pass
def buy(self):
browser.get(self.lineEdit.text())
while True:
try:
if browser.find_element_by_link_text('立即購(gòu)買'):
browser.find_element_by_link_text('立即購(gòu)買').click()
except:
pass
try:
if browser.find_element_by_link_text('提交訂單'):
browser.find_element_by_link_text('提交訂單').click()
now1 = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f')
self.lbl.setText("提交訂單時(shí)間為:%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')
# 對(duì)比時(shí)間,時(shí)間到的話就點(diǎn)擊結(jié)算
try:
if browser.find_element_by_link_text('立刻搶'):
browser.find_element_by_link_text('立刻搶').click()
except:
pass
try:
if browser.find_element_by_link_text('點(diǎn)擊領(lǐng)券'):
browser.find_element_by_link_text('點(diǎn)擊領(lǐng)券').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():
# 打開淘寶登錄頁(yè),并進(jìn)行掃碼登錄
browser.get("https://www.taobao.com")
time.sleep(3)
if browser.find_element_by_link_text("親,請(qǐng)登錄"):
browser.find_element_by_link_text("親,請(qǐng)登錄").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()
到此這篇關(guān)于python搶購(gòu)軟件/插件/腳本附完整源碼的文章就介紹到這了,更多相關(guān)python搶購(gòu)源碼內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!