I have been using ArcMap for a few years, but I have zero experience with Python or ArcPy. I have been looking for a way to check the links in my attribute table to see if they are broken, and by that I mean, which ones open to a 404-file not found page in a web browser . All my hyperlinks in the attribute table look like https://GIS.com/AsBuilts/PDF-NAME-HERE.pdf. I have had some exposure to other languages so I've been familiarizing myself with the code from this post: Using ArcPy to verify paths of Hyperlinks?. I got it working, but it always outputs all of rows in my attribute table to the broken links text file.
Which would mean that it thinks that all of my hyperlinks are broken?
I know for sure that there are some broken links and some that are good. I have linked them to the hyperlink tool in Arc and they open just fine.
I am not sure where to go from here, any suggestions of things to check?
Here's my code:
import arcpy import os fc = r"Z:\workplace\AsbuiltPoly_copy.shp" fields = ["ASBUILT_RE"] with arcpy.da.SearchCursor (fc,fields) as cursor: for row in cursor: Roll = str(row) if os.path.lexists(Roll): pass else: logfile = open(r"Z:\workplace\BrokenLinks.txt","a") logtext = Roll + os.linesep logfile.write(logtext) logfile.close()
I cannot download a link checker onto this computer cause I am not the admin :/ so I cannot go that route. But if you know anyone that are good, send them my way.