0

I need a code that automatically tests my URL every day with the webpagetest.org API

I'd like to do these tests with one Python script, run it once per day, and save the results to view later.

Dawson B
  • 1,224
  • 12
  • 16
diem_L
  • 389
  • 5
  • 22
  • SO is not a code writing service. Please read http://stackoverflow.com/help/how-to-ask and take the tour: https://stackoverflow.com/tour – Mike Scotty Apr 18 '17 at 09:12

1 Answers1

-1

Don't really understand what you're asking but you could write a script that is always run, or runs on start up and tests the URL.

For instance have a script running in the background consistently and sleep it for 23hrs 59 minutes. Example code:

import requests, time
from urllib.request import urlopen

def main():
    while(True):
        print("Good Morning")
        try:
            html_doc = urlopen("https://www.google.co.uk")
            print("Connection Established.")
        except:         
            raise ConnectionError("No connection can be made to the url")
        time.sleep(86400)

if __name__ == '__main__':
    main()

This will, once everyday, check the URL given to see if it can connect and display the result.

However I'm not sure this is what you want as the question is highly unclear, I would recommend you go and think about what exactly it is you want.

J. Scull
  • 309
  • 3
  • 13
  • This is not an answer to the question. OP was asking for help using the [webpagetest.org API](https://github.com/WPO-Foundation/webpagetest-docs/blob/master/dev/api.md) – Dawson B Dec 15 '20 at 17:35