OSX background script to check a URL until it produces a PDF file?

I have a document that is uploaded at work each month. It’s just a pdf.

I have the path to that file, but I’m tired of checking and checking until it’s available for download.

Can someone guide me to a solution that:

  1. starts checking the URL on a specific date; and
  2. keeps testing it until it produces a pdf; and
  3. download the pdf (yeah, goes without saying).

As a bonus, the URL includes the current month’s name (xxx) in the path. I’d like to grab the current month from my system’s date/time and adjust the URL accordingly as well as send a text to me when it’s all complete.

I could probably create 12 paths for the year and have it run the proper path based on the system date/time. Or, concatenate a text file to change the date.

Either way, steps 1-3 are more important.

Any guidance would help.

I’m new to scripting and have only made some basic tasks using AppleScript inside automator.