Select to view content in your preferred language

query any subscription for public content

723
2
06-06-2017 04:31 PM
MegHoole
Frequent Contributor

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
Frequent Contributor

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
Frequent Contributor

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

0 Kudos