Sure, it’s possibly breaking all sorts of style and best practice rules but it’s working for me. By default it will just echo the URL (for testing), switch the command assignment if you want it to actually add the image.
url = "https://vyos.net/get/nightly-builds/"
regex = r'\"(https:\/\/s3\.[^\"]*?\.iso)\"'
command = "echo This is the ISO URL: "
#command = "/opt/vyatta/bin/vyatta-op-cmd-wrapper add system image"
contents = requests.get(url)
match = re.search(regex, contents.text, re.I)
os.system(command + " " + match.group(1))
print("Error: Cannot find ISO URL")
print("Error: Cannot retrieve web page")
print("Error: Unhandled exception");
I’m always reluctant to do anything that will scrape a web page, one reason is due to load on the site. But this is only going to be run once per update anyway, just as if I’d browsed to the page myself and copied the latest URL.