How to automate a .py script that uses selenium to launch a browser and download files?

64 Views Asked by At

I am trying to download some .csv files from a website which offers no APIs and is restricted to browser. I have a fully functional .py file which does the job by launching an edge browser, selecting the right elements then downloading a zip file.

Now the problem is that I need to automate this task to run once everynight but due to graphical interfaces, the Windows Task Scheduler will not run the task unless the user is logged in.

I have tried SQL agent job as well. For both cases I have used .py script and .exe equivalent of it. No luck with SQL job at all, and with Win task scheduler, it only runs if user is logged in.

2

There are 2 best solutions below

0
J-San On

If you are not running it a Standard Windows account and not an Admin; the job will not run unless logged in. It's best practice to setup as a Windows admin. You can take a look at running it on a hosted VM or getting admin to set it up for you to run, just depending on your situation.

0
Aleister Crowley On

You mentioned that

"the Windows Task Scheduler will not run the task unless the user is logged in"

I assume this means that you try to run the task on your PC, but it is turned off?

You have two options here:

  1. You can set your PC to boot at certain times, you can do this in BIOS. Then, if you have no password on your Windows user account, it will log you in automatically. You can have a task scheduled for a couple of minutes after the planned boot and then plan a shutdown, so your PC does not consume power while idle.
  2. You can buy the cheapest VM possible, they start at $5 a month and run the task there - such VM would always be online, so no issues with turning your PC off.