query any subscription for public content

625
2
06-06-2017 04:31 PM
MegHoole
Occasional Contributor III

Looking for assistance to query any AGO subscription for public content, and dumping the info (owner, date published, type, access) into csv.

I've used the AGOLcat.py script off of github.. and it does everything I want to do, except requires username and password.   Not sure if that script can be modified to enable anonymous user to run the script where it would report only public content.

Thanks

2 Replies
SethLewis1
Occasional Contributor III

Meg,

The following should return public content from a given portal without needing a username/password.

from arcgis.gis import GIS
import csv
 
gis = GIS(input('Paste portal URL'))
 
items = gis.content.search('', max_items = 500)
 
fields = ['itemId', 'owner', 'type', 'title', 'created', 'modified', 'url', 'accessInformation']
with open('path', 'w', newline='') as outfile:
    csvfile = csv.writer(outfile)
    csvfile.writerow(fields)
   
    for item in items:
        row = [item.id, item.owner, item.type, item.title, item.created, item.modified, item.url, item.access]
        csvfile.writerow(row)
       
    print(outfile.name)
MegHoole
Occasional Contributor III

Thank you Seth!  I'll give that a try...

0 Kudos