I am using arcpro 3.3 and I have an attribute table with a field with hyperlinks to download files from the internet. Is there a tool or script to run to automatically do this?
Hi Jon,
Are you trying to download every linked item from each row of your table? Or are you trying to format hyperlinks so a pop-up will allow the user to download a selected link?
Best,
Bob
Hi Bob,
Happy Canada Day!
I am trying to download from every linked item in a row. The URL is in one field of the attribute table and there are many rows, too many to download one at a time.
Thanks,
Jon
Hi Jon,
Happy Canada Day to you!
So, to do the downloading automatically, I'd use a search cursor to iterate over the table and get the values from the URL field in a list.
https://pro.arcgis.com/en/pro-app/latest/arcpy/data-access/searchcursor-class.htm
You could make a list, my_urls, for example, and for each cycle of the search cursor append the URL string to the list.
https://www.w3schools.com/python/python_lists_add.asp
It would look something like this:
import arcpy
# path to table/feature class
fc = r'C:\Geology\OH\OH_geol_poly'
my_urls = []
# Use a search cursor to iterate through the table.
# For each row, get the attribute value in a field,
# and append it to a list.
with arcpy.da.SearchCursor(fc, 'SRC_URL') as cursor:
for row in cursor:
my_urls.append(row[0])
print(my_urls)
Once you have the URLs as a list, use Python to download them to your preferred location. There's an example here:
Best,
Bob