简体   繁体   English

关闭 Python Selenium 的命令行 window 使用 ZC89686A387D2BABC55BBatch3 运行后

[英]Close Python Selenium 's command line window after it runs using Window Batch

I use Python Selenium to do Web scraping, trigger it using a batch.bat file.我使用 Python Selenium 进行 Web 抓取,使用 batch.bat 文件触发它。 The chrome browser and the command line window still open after it runs successfully. chrome浏览器和命令行window运行成功后依然打开。 It should be closed because I put exit at the end of the batch script.它应该被关闭,因为我将 exit 放在批处理脚本的末尾。 see below code见下面的代码

timeout /t 2 /nobreak
"C:/Users/h/AppData/Local/Programs/Python/Python37/python.exe" "C:/Users/h/Desktop/Bbq/Python/Test.py"
timeout /t 12 /nobreak
exit

I look at the message in the cmd, here's the screenshot我看cmd中的消息,这是截图在此处输入图像描述

I wonder if any of the errors cause the problem?我想知道是否有任何错误导致问题? please advise.请指教。

use this exception to bypass all error, and force the brower to quit使用此异常绕过所有错误,并强制浏览器退出

import traceback.

try:
    print(abcd)
except :
    print(traceback.format_exc())

    print("ERROR")
finally:
    driver.quit()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM