How to "open" a URL from ec2 instance using cronjob

Viewed 45

Running the command below opens a page on chrome

python3 -m webbrowser https://www.python.org

What I am trying to do is create a cronjob that runs every night. This cronjob will be on an ec2 instance and all I want it to do is "open" the given page. There are metrics that will be recorded when the page is opened and loaded.

Tried

0 0 * * * curl -s "https://www.python.org" > /dev/null 2>&1

and

0 0 * * * python3 -m webbrowser https://www.python.org

(although I am not sure how this is supposed to work on a machine without browser)

but both didn't work as expected.

1 Answers
from selenium import webdriver

hyperlink = "https://www.python.org"
options = webdriver.ChromeOptions()
options.add_argument('--headless')
options.add_argument('--no-sandbox')

driver = webdriver.Chrome(options = options)
#driver = webdriver.Chrome()
driver.get(hyperlink)
 
navigationStart = driver.execute_script("return window.performance.timing.navigationStart")
responseStart = driver.execute_script("return window.performance.timing.responseStart")
domComplete = driver.execute_script("return window.performance.timing.domComplete")

backendPerformance_calc = responseStart - navigationStart
frontendPerformance_calc = domComplete - responseStart
 
print("Back End: %s" % backendPerformance_calc)
print("Front End: %s" % frontendPerformance_calc)
 
driver.quit()

source - https://www.lambdatest.com/blog/how-to-measure-page-load-times-with-selenium/

Related