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!
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:
Check Attribute URLs
Hi, I'm not really good at coding but I have a few hosted feature layers with multiple url fields that are not shared publically. When I test this code, it failed after I connected to the Server. I do not have a specific number after my hosted feature layer url. I tried to add the item ID # to the end and it didn't work, then so I tried to connect the Service as a feature layer collection, but I'm not sure if the coding was wrong or if I'm missing something. I'm very lost at this point and could use some help.
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.
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.
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')
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.