Hi Kathy,
Building on Seth's comment, here's a way you could scan the story map webpages in case you're using them as the primary section content. But if you're just embedding the URLs in the story map text, you could use the same idea to scan a list of URLs (see comments in the code), and schedule this script a couple times a week, receiving an email summary. I left what I have so far with the email component commented out-- I think I'm missing a credentials step to actually make it work, and I'm evidently not providing the correct server name. I currently get an error associated with server = smtplib.SMTP(srvr), which says
gaierror: [Errno 11001] getaddrinfo failed
But if you don't need an email, this will print the URL messages to the python command space.
import arcgis
from arcgis.gis import GIS
from arcgis.apps import storymap
import urllib, smtplib
from getpass import getpass
username='DCRAOpenData'
## Create a connection to your portal for publishing (enter your ArcGIS Online
## password in the textbox that appears, then hit 'Enter' on your keyboard)
gis = GIS("https://www.arcgis.com", username, getpass())
## Find the storymaps to verify URLS (you could also just provide a list of URLs
find_storymaps = gis.content.search("title: story map name/naming convention", item_type="Web Mapping Application", max_items=1, outside_org=False)
#srvr = 'server.domain.com'
#from_email = 'Name <email@domain.com>'
#to_email = 'Name <email@domain.com>'
#subject = 'URLs in story maps, script results'
msgs = []
for f in find_storymaps: ## Replace with code at bottom if just scanning list of URLS
print(f.title, f.id)
csmap = storymap.JournalStoryMap(gis.content.get(str(f.id)))
sections = csmap.properties["values"]["story"]["sections"]
for s in sections:
if s["media"]["type"] == "webpage":
url = s["media"]["webpage"]["url"]
try:
response_code = urllib.request.urlopen(url).getcode()
print(str(url) + ' in the ' + str(s["title"]) + ' section is current and accessible!')
except IOError:
print('---- URL not funtional: ' + str(url) + '----')
msgs.append('---- URL not funtional: ' + str(url) + '----')
## If no errors were found, configure messages to say so
if msgs == []:
msgs.append('All URLs are functional!')
##Set up the email of the final messages and send it
#final_msg = " ".join(msgs)
#email = """\
#From: %s
#To: %s
#Subject: %s
#%s
#""" % (from_email, to_email, subject, final_msg)
#server = smtplib.SMTP(srvr)
#server.sendmail(from_email, to_email, final_msg)
#server.quit()
### IF SCANNING A LIST OF URLS ###
#for f in find_storymaps:
# try:
# response_code = urllib.request.urlopen(url).getcode()
# except IOError:
# print('---- URL not funtional: ' + str(url) + '----')
# msgs.append('---- URL not funtional: ' + str(url) + '----')