Hello-
I have an AGOL hosted feature layer with about 50 features. Each feature has at least one URL to link to external websites for more information. Is there a tool within AGOL or ArcGIS Pro that will test each URL to make sure they're valid?
Thanks!
Solved! Go to Solution.
I'm not aware of a tool in ArcGIS Online or Pro, however, we have a lot of users with this same need in our organization. Enough that we built and shared an ArcGIS Online Notebook that tests URLs in an attribute field in a feature service (hosted feature layer) the user specifies; much like the solution @jcarlson suggested.
Feel free to give it a try:
You could probably do this with the Python API, combined with the requests module.
from arcgis import GIS
import requests
# connect to portal
gis = GIS('url', 'user', 'password')
# get feature layer
fl = gis.content.get('itemID').layers[0]
# query out to dataframe
df = fl.query(out_fields=['url_field'], as_df=True)
# pull out url field as list
urls = df['url_field'].to_list()
# check each URL in list, print invalid URLs
for u in urls:
response = requests.get(u)
if response.status_code == 404:
print(f'{u} not a valid URL')
Thanks! I ended up using Peter Knoop's solution below but yours pretty much uses the same steps. I'm a coding novice and his notebook seemed easier for me to follow, but may try this as well to see which fits better in my workflow.
I'm not aware of a tool in ArcGIS Online or Pro, however, we have a lot of users with this same need in our organization. Enough that we built and shared an ArcGIS Online Notebook that tests URLs in an attribute field in a feature service (hosted feature layer) the user specifies; much like the solution @jcarlson suggested.
Feel free to give it a try:
Thanks, Peter! this was super easy to follow for a coding novice like myself and it worked perfectly. One exception: I got an error when trying to run the %%time magic command, so I edited it to %time and it worked that way.