I grabbed code from JoshuaSharp-Heward here Simple way to export a Layer List for a Web Map to... - Esri Community
and tweaked it a little to output the layer url with the layer name. Unfortunately I keep running into an issue where one of the items has no attribute and it causes the program to fail. I am trying to write in an exception but don't know how. any help would be appreciated. The exact error is "layer" instance has no attribute 'url'
from arcgis.gis import GIS
from arcgis.mapping import WebMap
gis = GIS('pro')# if running this from Notebook for ArcGIS in AGOL/Enterprise, replace this line with gis = GIS('home')
wmItemId = "" #put the id of the webmap in here
wmItem = gis.content.get(wmItemId)
wm = WebMap(wmItem)
print('\033[1m' +"MapName" )
for lyr in wm.layers:
print('\033[0m' + lyr.title + "\n" + lyr.url)