栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

TB抢购购程序

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

TB抢购购程序

from selenium import webdriver
import datetime
import time

def login():
    # 打开淘宝首页,扫码登陆淘宝
    driver.get("https://www.XXXXXX.com")
    time.sleep(3)
    if driver.find_element_by_xpath("//*[@id='J_SiteNavLogin']/div[1]/div[1]/a[1]"):
        driver.find_element_by_xpath("//*[@id='J_SiteNavLogin']/div[1]/div[1]/a[1]").click()
        print("请在15秒内完成扫码")
        time.sleep(10)
        # 打开购物车列表首页
        driver.get("https://cart.taobao.com/cart.htm")
        time.sleep(3)
    # 全选购物车
    while True:
        print(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
        if datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") >= times and driver.find_element_by_id("J_SelectAll1"):
            driver.find_element_by_id("J_SelectAll1").click()
            break
    print("select success"+datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"))


def buy(times):
    while True:
        # 对比时间,时间到的话就点击结算
        try:
            if driver.find_element_by_id("J_Go"):
                driver.find_element_by_id("J_Go").click()
                driver.find_element_by_link_text('提交订单').click()
                print('抢购成功,请尽快付款')
        except:
            print('请再次尝试提交订单')
        time.sleep(0.1)


if __name__ == "__main__":
    driver = webdriver.Chrome()
    times = input("请输入抢购时间(例如格式:):{}".format(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")))
    login()
    buy(times)

 

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/656530.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号