|
楼主 |
发表于 2022-9-9 16:31:26
|
显示全部楼层
cmd 显示:
C:\Users\逝灬去>import datetime
'import' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
C:\Users\逝灬去>import time
'import' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
C:\Users\逝灬去>py -m pip install pywin32
Collecting pywin32
Downloading pywin32-304-cp310-cp310-win_amd64.whl (12.1 MB)
Pycharm 显示:
D:\python\python.exe C:/Users/逝灬去/Desktop/taobao.py
Traceback (most recent call last):
File "D:\python\lib\site-packages\selenium\webdriver\common\service.py", line 71, in start
self.process = subprocess.Popen(cmd, env=self.env,
File "D:\python\lib\subprocess.py", line 969, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "D:\python\lib\subprocess.py", line 1438, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] 系统找不到指定的文件。
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\逝灬去\Desktop\taobao.py", line 19, in <module>
browser = webdriver.Chrome()
File "D:\python\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 69, in __init__
super().__init__(DesiredCapabilities.CHROME['browserName'], "goog",
File "D:\python\lib\site-packages\selenium\webdriver\chromium\webdriver.py", line 89, in __init__
self.service.start()
File "D:\python\lib\site-packages\selenium\webdriver\common\service.py", line 81, in start
raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://chromedriver.chromium.org/home
进程已结束,退出代码为 1
现在的代码是:
##########淘宝购物车秒杀###########
#从..工具箱 拿出...工具
from selenium import webdriver
times = "2022-09-09 22:00:00.000000"
browser = webdriver.Chrome()
time.sleep(3)
browser.get("https://www.taobao.com")
time.sleep(3)
browser.find_element_by_link_text("亲,请登录").click()
print(f"请尽快扫码登录")
time.sleep(10)
browser.get("https://cart.taobao.com/cart.htm")
time.sleep(5)
# 是否全选购物车
while True:
if browser.find_element_by_id("J_ SiteFooter"):
browser.find_element_by_id("J_ SiteFooter").click()
break
while True:
#获取电脑现在的时间
now = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f')
# 对比时间,时间到的话就点击结算
print(now)
#判断是不是到了秒杀时间? >
if now > times:
# 点击结算按钮
while True:
try:
if browser.find_element_by_link_text("结 算"):
browser.find_element_by_link_text("结 算").click()
print(f"主人,结算提交成功,我已帮你抢到商品啦,请及时支付订单")
speaker.Speak(f"主人,结算提交成功,我已帮你抢到商品啦,请及时支付订单")
break
except:
pass
#点击提交订单按钮
while True:
try:
if browser.find_element_by_link_text('提交订单'):
browser.find_element_by_link_text('提交订单').click()
print(f"抢购成功,请尽快付款")
except:
print(f"主人,我已帮你抢到商品啦,您来支付吧")
break
time.sleep(0.01)
|
|