首页 > 其他分享 >脚本

脚本

时间:2023-10-28 09:02:54浏览次数:22  
标签:脚本 datetime 下单 time print import page

import time
import datetime

from playwright.sync_api import sync_playwright
import pytest
from selenium.common import NoSuchElementException, ElementNotInteractableException
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait

def pay():
    # playwrightUI自动化工具
    with sync_playwright() as playwright:
        context = playwright.chromium.launch_persistent_context(
            user_data_dir="../",
            headless=False,
            slow_mo=500,
            viewport={'width': 1920, 'height': 1080}
        )

        page = context.new_page()

        # 设置商品地址
        page.goto("https://www.vmall.com/product/10086429395667.html")
        # page.goto("https://www.vmall.com/product/10086847911493.html")

        # #点击登录
        # if page.locator("#up_loginName").is_hidden():
        #     page.click("#top-index-loginUrl")
        #
        # # 检测是否跳到商品页,等待2分钟,超过就超时,手动登录操作需要时间
        # page.wait_for_selector(selector="#pro-name",timeout=3*60*1000)

        tomorrow = datetime.datetime.combine(datetime.datetime.today(), datetime.time(hour=8, minute=8, second=0))
        print("抢购日期:"+tomorrow.strftime("%Y-%m-%d %H:%M:%S.%f"))
        while tomorrow.timestamp() >= datetime.datetime.now().timestamp():
            localtime = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f")[:-3]
            print(localtime)
            time.sleep(0.01)

        # 点击下单
        try:
            print('尝试下单')
            start_time = time.time()
            x = page.get_by_text("立即下单").first.click()
        except:
            print(f'下单失败, 再次尝试, used time: {time.time() - start_time}')
            time.sleep(0.5)

        try:
            # 点击确认下单
            time.sleep(0.1)
            page.mouse.wheel(0, 7000)
            page.locator('[seed="checkout-submit"]').click()
            print('提交订单成功')
        except:
            print('下单成功,手动提交订单吧!')
        time.sleep(9000)



if __name__ == "__main__":
    pay()

标签:脚本,datetime,下单,time,print,import,page
From: https://www.cnblogs.com/hui-code/p/17793470.html

相关文章

  • shell 脚本一键部署 k8s 高可用集群
    github地址:https://github.com/Johnny-Demo/deploy/tree/k8s-cluster有不理解的地方可以私信我......
  • 如何使用SHC对Shell脚本进行封装和源码隐藏
    在许多情况下,我们需要保护我们的shell脚本源码不被别人轻易查看。这时,使用shc工具将shell脚本编译成二进制文件是一个有效的方法。本文将详细介绍如何在线和离线条件下安装shc,并将其用于编译你的脚本。什么是SHC?shc是一个由C语言编写的Shell脚本加密程序,它可以将你的脚本编译成......
  • os: ubuntu23.10 -- 更新脚本(update)
    os:ubuntu23.10--更新脚本(update)    一、ubuntu23.10更新脚本1[wit@ubuntu:null]$cat~/user/tools/update2#!/usr/bin/envbash3456echo"----update----";7echo;8echo211224ln|sudo-Sdate"+%F%T";9echo21......
  • 实用小脚本——Windows系统使用dos命令删除文件
    @echooff&color0aset/pff=输入文件名:title查找%ff%echo.&set/p=正在查找<nulfor%%iin(cdefgh)do(ifexist%%i:\ (cd/d%%i:\set/p=%%i:<nulfor/f "delims="%%jin('dir/b/a-d/s"%ff%"2^>nul')do(echo.&......
  • calibredrv 做 LVL 脚本
    calibredrv做LVL的脚本脚本是一个makefile文件,执行的时候先执行makegen,再运行makediff。oasis文件target=/xxx/xxx.oasref=/xxx/xxx.oastarget_top=topCellNameref_top=topCellNamegen:dbdiff-systemOASIS-refdesign$(ref)$(ref_top)-desi......
  • 写一个cmd脚本,列出指定目录下的所有子目录和文件,限制层数
    在Windows的CMDshell中,tree命令并不直接支持指定层数。你可以编写CMD脚本达到相同目标。@echooffsetlocalset"root=%~1"set"maxdepth=%~2"set"curdepth=0"set"indent=":looppushd"%root%"for/d%%Din(*)do(echo%indent%......
  • 【速看】如何通过合理的封装,让你的自动化脚本更上一层楼!
    此文章来源于项目官方公众号:“AirtestProject”版权声明:允许转载,但转载必须保留原链接;请勿用作商业或者非法用途1.前言 上一篇推文利用一个在图片范围内实现随机坐标点击的例子,去教会大家如何将自己想要的效果实现出来,受到大家的热情反响,在我们官方讨论群中,还有大佬对我......
  • Linux免密登录脚本
    首先安装sshpassyuminstall-ysshpassLinux免密登录脚本:#!/bin/bashexportIP="192.168.100.140192.168.100.141192.168.100.142"exportSSHPASS=086530forHOSTin$IP;dosshpass-essh-copy-id-oStrictHostKeyChecking=no$HOST scp/etc/hostsroot@$H......
  • Mac电脑使用BetterAndBetter软件自定义的脚本
    新建文件tellapplication"Finder" setselectedItemstoselection if(countofselectedItems)is1then setselectedItemtoitem1ofselectedItems ifclassofselectedItemisfolderthen displaydialog"请输入文件名:"defaultansw......
  • sipp3.6多方案压测脚本
     概述SIP压测工具sipp,免费,开源,功能足够强大,配置灵活,优点多。有时候我们需要模拟现网的生产环境来压测,就需要同时有多个sipp脚本运行,并且需要不断的调整呼叫并发。通过python脚本的子进程功能,我们可以很方便的实现sipp的多方案压测功能。环境centos7.9freeswitch1.10.7si......