前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >华为商城抢购mate 60手机的自动化python代码2024.1.8

华为商城抢购mate 60手机的自动化python代码2024.1.8

作者头像
用户7138673
发布2024-01-10 13:57:19
5240
发布2024-01-10 13:57:19
举报
文章被收录于专栏:大大的小数据大大的小数据

1、打开浏览器

2、手动登陆

3、在时间范围内反复寻找,"立即下单""提交订单"按钮,一旦出现就按

4、手动支付

代码语言:javascript
复制
import datetime
from selenium import webdriver
from selenium.webdriver.common.by import By

# 启动Chrome浏览器
driver = webdriver.Chrome()
# 打开华为商城
url = "https://www.vmall.com/index.html"
driver.get(url)
driver.maximize_window()  # 窗口最大化

# 人工登录华为商城
# ...

# 打开要购买商品的页面
product_url = "https://www.vmall.com/product/10086970184614.html"  # Mate60产品ID
driver.get(product_url)

# # 设置抢购时间
start_time_str = "2024-1-8 16:07:50"
start_time = datetime.datetime.strptime(start_time_str, "%Y-%m-%d %H:%M:%S")
end_time = start_time + datetime.timedelta(seconds=180)  # 抢购截止时间设置为3分钟后

# 开始抢购
while True:
    now = datetime.datetime.now()
    if now >= start_time:
        while True:
            print('重试1')
            try:
                driver.find_element(By.LINK_TEXT, "立即下单").click()
                # driver.find_element(By.LINK_TEXT, "即将开始").click()
                print('点击到-立即下单')
                break
            except:
                now = datetime.datetime.now()
                if now > end_time:
                    print('卡在立即下单')
                    break
                else:
                    pass
        
        while True:
            print('重试2')
            try:
                driver.find_element(By.LINK_TEXT, "提交订单").click()
                # print("抢到啦!!!快去支付")
                # driver.find_element(By.LINK_TEXT, "即将开始").click()
                print('点击到-提交订单')
                break
            except:
                now = datetime.datetime.now()
                if now > end_time:
                    print('卡在支付')
                    break
                else:
                    pass
        break

# 支付操作需要人工完成

参考:

https://zhuanlan.zhihu.com/p/663498713

https://www.bilibili.com/video/BV1D34y1P7vw

本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2024-01-08,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 大大的小数据 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档