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

Python淘寶秒殺的腳本實現(xiàn)

 更新時間:2023年01月06日 14:42:48   作者:fakerth  
這篇文章主要介紹了Python淘寶秒殺的腳本實現(xiàn),文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧

準備工作

我們需要把秒殺的商品加入購物車,因為腳本點擊的是全選,所以不需要的商品要移出購物車。

過程分析

1.打開某寶網(wǎng)站;

pq = webdriver.Chrome()
pq.get("https://www.taobao.com")  # 版權問題
time.sleep(3)

sleep的原因是怕萬一網(wǎng)速慢,網(wǎng)頁加載慢。

2.掃碼登陸;

pq.find_element(By.LINK_TEXT, "親,請登錄").click()
print(f"請盡快掃碼登錄")
time.sleep(10)

自動點擊進入登錄頁面,我們點擊掃碼登錄進行掃碼。
3.進入購物車;

pq.get("https://cart.taobao.com/cart.htm")
time.sleep(3)

登錄成功后,直接進入購物車網(wǎng)站。

4.全選購物車;

while True:
    try:  # 查找 元素 來自  ID
        if pq.find_element(By.ID, "J_SelectAll1"):
            pq.find_element(By.ID, "J_SelectAll1").click()
            break
    except:
        print(f"找不到購買按鈕")

找到全選按鈕,全選。

在這里插入圖片描述

5.結算。

while True:
    # 獲取電腦現(xiàn)在的時間,                      year month day
    now = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f')
    # 對比時間,時間到的話就點擊結算
    print(now)
    if now > lisi:
        # 點擊結算按鈕
        while True:
            try:
                if pq.find_element(By.LINK_TEXT, "結 算"):
                    print("here")
                    pq.find_element(By.LINK_TEXT, "結 算").click()
                    print(f"主人,程序鎖定商品,結算成功")
                    break
            except:
                pass
        while True:
            try:
                if pq.find_element_by_link_text('提交訂單'):
                    pq.find_element_by_link_text('提交訂單').click()
                    print(f"搶購成功,請盡快付款")
            except:
                print(f"主人,結算提交成功,我已幫你搶到商品啦,請及時支付訂單")
                speaker.Speak(f"主人,結算提交成功,我已幫你搶到商品啦,請及時支付訂單")
                break
        time.sleep(0.01)

在這里插入圖片描述

獲取現(xiàn)在時間與秒殺時間進行比對,時間一到點擊提交訂單生成訂單,生成訂單后支付時間就不需要緊張了。

在這里插入圖片描述

完整程序實現(xiàn)如下:

import datetime
import win32com.client
import time
from selenium.webdriver.common.by import By
from selenium import webdriver

now = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f')
speaker = win32com.client.Dispatch("SAPI.SpVoice")

lisi = "2022-11-11 20:00:00.00000000"
zhangsan = webdriver.Chrome()
zhangsan.get("https://www.taobao.com")
time.sleep(3)  # 查找  網(wǎng)絡元素 來自 鏈接 文本(親,請登錄)    #點擊
zhangsan.find_element(By.LINK_TEXT, "親,請登錄").click()
print(f"請盡快掃碼登錄")
time.sleep(10)
zhangsan.get("https://cart.taobao.com/cart.htm")
time.sleep(3)

# 是否全選購物車
while True:
    try:  # 查找 元素 來自  ID
        if zhangsan.find_element(By.ID, "J_SelectAll1"):
            zhangsan.find_element(By.ID, "J_SelectAll1").click()
            break
    except:
        print(f"找不到購買按鈕")
while True:
    # 獲取電腦現(xiàn)在的時間,                      year month day
    now = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f')
    # 對比時間,時間到的話就點擊結算
    print(now)
    if now > lisi:
        # 點擊結算按鈕
        while True:
            try:
                if zhangsan.find_element(By.LINK_TEXT, "結 算"):
                    print("here")
                    zhangsan.find_element(By.LINK_TEXT, "結 算").click()
                    print(f"主人,程序鎖定商品,結算成功")
                    break
            except:
                pass
        while True:
            try:
                if zhangsan.find_element_by_link_text('提交訂單'):
                    zhangsan.find_element_by_link_text('提交訂單').click()
                    print(f"搶購成功,請盡快付款")
            except:
                print(f"主人,結算提交成功,我已幫你搶到商品啦,請及時支付訂單")
                speaker.Speak(f"主人,結算提交成功,我已幫你搶到商品啦,請及時支付訂單")
                break
        time.sleep(0.01)

到此這篇關于Python淘寶秒殺的腳本實現(xiàn)的文章就介紹到這了,更多相關Python淘寶秒殺內容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!

相關文章

最新評論