Hello Everyone!
I have a feature class that has 700+ records in the attribute table. Each record links to a specific url location. I can get python to extra the unique url (hyperlink). How do I get python to go to the url?
Also, how do I get the record / row to highlight in the attribute table + zoom to that record (zoom to selected).
Thx!
Gail
Hi Gail,
Can you clarify what you mean by "go to the url" ? Are you trying to get the text from page or do you want to load the url in a web browser?
For the second part, you can use Select Layer By Attribute—Help | ArcGIS for Desktop and then use zoomToSelectedFeatures. Below is a sample for ArcMap:
mxd = arcpy.mapping.MapDocument('/path/to/mxd')
df = arcpy.mapping.ListDataFrames(mxd, "Layers") [0]
lyr = arcpy.mapping.ListLayers(mxd, "Target_Layer", df)[0]
arcpy.SelectLayerByAttribute_management(lyr, "NEW_SELECTION", ' "id" = 1234 ')
df.zoomToSelectedFeatures()
Hope this helps,
Earl
Hi Earl. Thx for the Select info. Much appreciated.
I would like the python script to open the url. The url links to a specific location - example: https://marinecadastre.gov/espis/#/search/study/322
How do I get the script to automatically open this url?
Hi Gail,
I'm still not sure what you mean by open, but I'll assume you mean to open in a browser. For something like that, you could use selenium · PyPI .
-Earl
Hi Earl:
I was able to open the below hyperlink / url in a web browser. The web browser takes a few seconds to open up, but it does open and goes to the right url (study # 397) . Note: urllink value was captured using row.getValue(urlfield)
# OPENS A HYPERLINK
import webbrowser
webbrowser.open(urllink) # https://marinecadastre.gov/espis/#/search/study/397