<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Scan organization for items using a specific service url in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/search-items-using-a-specific-service-url/m-p/1253030#M50024</link>
    <description>&lt;P&gt;If you're comfortable with a bit of Python, this is pretty doable using the ArcGIS Python API. Items added "from the web" will be stored in the map's JSON, and this is searchable.&lt;/P&gt;&lt;P&gt;Here's a little script we run when we're looking for dependencies. This is written for checking within a single Portal, but could easily adapt for cross-portal checking by entering the URL instead of the itemID.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis import GIS
from arcgis.mapping import WebMap
import pandas as pd

# connect to portal
gis = GIS('your portal url', 'user', 'pass')

print('Let''s find some dependencies!')
print('Works best w/ ItemID, but you can use a URL, too.')

itemid = input('Enter ItemID (leave empty for URL): ')

item = gis.content.get(itemid)

# check item type. pull url if service
if item.type in ['Feature Service', 'Tile Layer', 'Map Service']:
    itemurl = gis.content.get(itemid).url if itemid else input('Service URL: ')
    
    print('Feature service detected. Looking for web maps with this layer.')
    webmaps = gis.content.search('', item_type='Web Map', max_items=-1)
    map_list = [m for m in webmaps if str(m.get_data()).find(itemurl) &amp;gt; -1]
    print(f'{len(map_list)} maps found!')

elif item.type in ['Web Map']:
    print('Web map detected. Checking for apps that reference this map.')
    map_list = [item]
else:
    itemurl = 'no url'

# get apps that reference url or matched maps
apptypes = ['Application', 'Dashboard', 'Story Map', 'Web Experience']
webapps = [item for sublist in [gis.content.search('', item_type=t, max_items=-1) for t in apptypes] for item in sublist]

app_list = []

for w in webapps:
    
    try:
        wdata = str(w.get_data())

        criteria = [
            wdata.find(find_url) &amp;gt; -1,
            wdata.find(find_id) &amp;gt; -1,
            any([wdata.find(m.id) &amp;gt; -1 for m in map_list])
        ]
        
        if any(criteria):
            app_list.append(w)
    
    # Some apps don't have data, so we'll just skip them if they throw a TypeError
    except:
        continue
    
print(f'{len(app_list)} apps found!')

# create dataframe
dependencies = pd.concat(
    [
        pd.DataFrame([{'title':a.title, 'id':a.id, 'type':a.type, 'url':f'{gis.url}/home/item.html?id={a.id}'} for a in app_list]),
        pd.DataFrame([{'title':m.title, 'id':m.id, 'type':m.type, 'url':f'{gis.url}/home/item.html?id={m.id}'} for m in map_list])
    ]
)

dependencies.to_csv('dependencies.csv')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 30 Jan 2023 19:28:39 GMT</pubDate>
    <dc:creator>jcarlson</dc:creator>
    <dc:date>2023-01-30T19:28:39Z</dc:date>
    <item>
      <title>search items using a specific service url</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/search-items-using-a-specific-service-url/m-p/1253025#M50023</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;We want to remove a set of mapServices that are hosted on ArcGIS Enterprise. We would like to know if some items in ArcGIS Online were created using those mapServices before pulling the plug.&lt;/P&gt;&lt;P&gt;Is there a way to scan ArcGIS Online content using a specific url so items that were added "from the web" could be find?&lt;BR /&gt;&lt;BR /&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jan 2023 13:51:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/search-items-using-a-specific-service-url/m-p/1253025#M50023</guid>
      <dc:creator>MaximeDemers</dc:creator>
      <dc:date>2023-01-31T13:51:07Z</dc:date>
    </item>
    <item>
      <title>Re: Scan organization for items using a specific service url</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/search-items-using-a-specific-service-url/m-p/1253030#M50024</link>
      <description>&lt;P&gt;If you're comfortable with a bit of Python, this is pretty doable using the ArcGIS Python API. Items added "from the web" will be stored in the map's JSON, and this is searchable.&lt;/P&gt;&lt;P&gt;Here's a little script we run when we're looking for dependencies. This is written for checking within a single Portal, but could easily adapt for cross-portal checking by entering the URL instead of the itemID.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis import GIS
from arcgis.mapping import WebMap
import pandas as pd

# connect to portal
gis = GIS('your portal url', 'user', 'pass')

print('Let''s find some dependencies!')
print('Works best w/ ItemID, but you can use a URL, too.')

itemid = input('Enter ItemID (leave empty for URL): ')

item = gis.content.get(itemid)

# check item type. pull url if service
if item.type in ['Feature Service', 'Tile Layer', 'Map Service']:
    itemurl = gis.content.get(itemid).url if itemid else input('Service URL: ')
    
    print('Feature service detected. Looking for web maps with this layer.')
    webmaps = gis.content.search('', item_type='Web Map', max_items=-1)
    map_list = [m for m in webmaps if str(m.get_data()).find(itemurl) &amp;gt; -1]
    print(f'{len(map_list)} maps found!')

elif item.type in ['Web Map']:
    print('Web map detected. Checking for apps that reference this map.')
    map_list = [item]
else:
    itemurl = 'no url'

# get apps that reference url or matched maps
apptypes = ['Application', 'Dashboard', 'Story Map', 'Web Experience']
webapps = [item for sublist in [gis.content.search('', item_type=t, max_items=-1) for t in apptypes] for item in sublist]

app_list = []

for w in webapps:
    
    try:
        wdata = str(w.get_data())

        criteria = [
            wdata.find(find_url) &amp;gt; -1,
            wdata.find(find_id) &amp;gt; -1,
            any([wdata.find(m.id) &amp;gt; -1 for m in map_list])
        ]
        
        if any(criteria):
            app_list.append(w)
    
    # Some apps don't have data, so we'll just skip them if they throw a TypeError
    except:
        continue
    
print(f'{len(app_list)} apps found!')

# create dataframe
dependencies = pd.concat(
    [
        pd.DataFrame([{'title':a.title, 'id':a.id, 'type':a.type, 'url':f'{gis.url}/home/item.html?id={a.id}'} for a in app_list]),
        pd.DataFrame([{'title':m.title, 'id':m.id, 'type':m.type, 'url':f'{gis.url}/home/item.html?id={m.id}'} for m in map_list])
    ]
)

dependencies.to_csv('dependencies.csv')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Jan 2023 19:28:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/search-items-using-a-specific-service-url/m-p/1253030#M50024</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2023-01-30T19:28:39Z</dc:date>
    </item>
    <item>
      <title>Re: Scan organization for items using a specific service url</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/search-items-using-a-specific-service-url/m-p/1253031#M50025</link>
      <description>&lt;P&gt;Thank you so much for sharing this! I will definately go that way!&lt;/P&gt;</description>
      <pubDate>Mon, 30 Jan 2023 19:31:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/search-items-using-a-specific-service-url/m-p/1253031#M50025</guid>
      <dc:creator>MaximeDemers</dc:creator>
      <dc:date>2023-01-30T19:31:57Z</dc:date>
    </item>
  </channel>
</rss>

