Use selenium crawler timing task to complete the cmd window is not closed

Small report

Scenario: Today, I used the windows server to set up a timed task to crawl data, that is, set up a timed task on the computer and then create a new batch (bat) to execute the py program.

The normal situation is to run the bat, the cmd window will automatically close after the execution is completed, other crawlers I wrote can be automatically closed, the reason is locked to the selenium framework .

1. How to automatically close the cmd window

Add after executing the program code

exit  @cmd.exe   
         cmd

Too much, I checked most methods on the Internet, and it didn’t respond.

The result is still stuck in the result after running, as shown in the figure

 Two, close the cmd program through python

os.popen('exit.exe')
sys.exit()

After a few tries, there is still no response ==

But this cmd window, as long as you press CTRL+C, it will be turned off == I just want to make a simulation of manually pressing the keyboard, it’s just fine if I just think about it, I can’t write it.

 

3. Sudden surprise

I thought about writing and closing the cmd program code directly in the batch. Can it be turned off? Results look down

What the hell am I losing this. . . . Forget it, go to the task manager to see if cmd can be set to close

what! Originally, the program for displaying cmd on the desktop has always been chromedriver.exe. Now it’s easy to batch process and turn off this program.

taskkill /F /FI "imagename eq chromedriver.exe"

Harm == If you guys might solve this problem in minutes, don’t laugh at me, Tang Xiaobai, hahahahahahahahahahaha

 

Guess you like

Origin blog.csdn.net/tang242424/article/details/109909736