So I have a Python Selenium script that opens chrome, gets information, and then closes. My script is done, and I want to run it daily every 5 minutes. But how do schedule the script to do that? And how to make sure that the browser doesn't open every 5 minutes, but just does it on the background. (Or maybe on a server?) I am new to programming so could anyone describe it very detailed how to do it? Thank you so much!
2 Answers
Regarding running the script on a schedule, you are looking for a cron job.
how to make sure that the browser doesn't open every 5 minutes, but just does it on the background.
-- for this, I'm not sure what binding language, browser, or initilization setup you are using, but I think you want to run the browser in headless mode.
1 Comment
Simon
Should my computer stay on the whole time then?
To make sure the browser opens in the background you can use Selenium's headless chrome option like this
from selenium import webdriver
options = webdriver.ChromeOptions()
options.headless = True
driver = webdriver.Chrome(CHROMEDRIVER_PATH, options=options)
To make the script run in interval you will have to use something like crontab for Linux or Windows Task Scheduler for windows