1 Star 0 Fork 0

618859/python-miao-sha

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
index.py 1.41 KB
一键复制 编辑 原始数据 按行查看 历史
618859 提交于 2023-09-17 12:04 . first
from selenium import webdriver
import datetime
import time
from selenium.webdriver.common.by import By
options = webdriver.ChromeOptions()
driver = webdriver.Chrome()
driver.maximize_window()
# 登录函数
def login():
driver.get("https://www.taobao.com")
time.sleep(3)
if driver.find_element(By.LINK_TEXT, "亲,请登录"):
driver.find_element(By.LINK_TEXT, "亲,请登录").click()
print("请在20秒内完成登录")
time.sleep(20)
# 进入购物车
driver.get("https://cart.taobao.com/cart.htm")
time.sleep(3)
if driver.find_element(By.ID, "J_SelectAll1"):
driver.find_element(By.ID, "J_SelectAll1").click()
now = datetime.datetime.now()
print("login success:",now.strftime("%Y-%m-%d %H:%M:%S"))
def buy(buytime):
while True:
now = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f")
if now > buytime:
try:
if driver.find_element(By.ID, "J_Go"):
driver.find_element(By.ID, "J_Go").click()
time.sleep(0.5)
driver.find_element(By.LINK_TEXT, "提交订单").click()
print("恭喜你,购买成功!")
except:
time.sleep(0.1)
else:
print(now)
time.sleep(0.1)
if __name__ == "__main__":
login()
buy("2023-09-17 11:49:30.000")
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/618859/python-miao-sha.git
[email protected]:618859/python-miao-sha.git
618859
python-miao-sha
python-miao-sha
master

搜索帮助