<?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: Python Download Automation in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/python-download-automation/m-p/1111223#M42748</link>
    <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/292435"&gt;@DaveTenney&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You are very welcomed!&amp;nbsp; So happy it worked out for you!&lt;/P&gt;</description>
    <pubDate>Tue, 26 Oct 2021 12:58:43 GMT</pubDate>
    <dc:creator>ABishop</dc:creator>
    <dc:date>2021-10-26T12:58:43Z</dc:date>
    <item>
      <title>Python Download Automation</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/python-download-automation/m-p/1110231#M42687</link>
      <description>&lt;P&gt;I need assistance with an interesting issue im experiencing when i try to automate the download process from agol to local drive. Im utilizing python3 to automate the download process, i can manually log in and manually download the fgdb of the data on agol. Once i attempt to do the same steps with the python script it fails when it attempts to download the data with an error code 403.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;here is my script:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;from time import strftime&lt;BR /&gt;print(strftime('%c'))&lt;/P&gt;&lt;P&gt;from arcgis.gis import GIS&lt;/P&gt;&lt;P&gt;#variables#&lt;BR /&gt;itemid = 'itemid number goes here'&lt;BR /&gt;output = r'C:\Temp\AGOLtest'&lt;BR /&gt;tempfile = strftime('Test_%m_%d_%y')&lt;/P&gt;&lt;P&gt;#variables for testing#&lt;BR /&gt;##itemid = 'testing itemid goes here'&lt;BR /&gt;##output = r'C:\Temp\AGOLtest'&lt;BR /&gt;##tempfile = strftime('Test_%m_%d_%y')&lt;/P&gt;&lt;P&gt;#file pull#&lt;BR /&gt;gis = GIS('URL', 'un', 'pw')&lt;BR /&gt;print(gis)&lt;BR /&gt;print('access to agol successful')&lt;BR /&gt;arcgisitem = gis.content.get(itemid)&lt;BR /&gt;print(arcgisitem)&lt;BR /&gt;print('access to agol item successful')&lt;BR /&gt;print(tempfile)&lt;BR /&gt;arcgisitem.export(tempfile, 'File Geodatabase', parameters=None, wait=True)&lt;BR /&gt;print(tempfile)&lt;BR /&gt;print('item export to agol complete')&lt;BR /&gt;myexport = gis.content.search(tempfile, item_type='File Geodatabase')&lt;BR /&gt;print('search for agol content item complete')&lt;BR /&gt;print(myexport)&lt;BR /&gt;print(myexport[0])&lt;BR /&gt;print(myexport[0].itemid)&lt;BR /&gt;fgdb = gis.content.get(myexport[0].itemid)&lt;BR /&gt;print('found fgdb export on agol content page')&lt;BR /&gt;fgdb.download(save_path=output)&lt;BR /&gt;print('export downloaded to folder location')&lt;BR /&gt;fgdb.delete()&lt;BR /&gt;print('export has been deleted from agol content page')&lt;/P&gt;&lt;P&gt;print('Script completed at {}'.format(strftime('%c')))&lt;/P&gt;</description>
      <pubDate>Fri, 22 Oct 2021 14:04:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/python-download-automation/m-p/1110231#M42687</guid>
      <dc:creator>DaveTenney</dc:creator>
      <dc:date>2021-10-22T14:04:02Z</dc:date>
    </item>
    <item>
      <title>Re: Python Download Automation</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/python-download-automation/m-p/1110236#M42688</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/292435"&gt;@DaveTenney&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Are you using ArcGIS Pro?&amp;nbsp; Version?&lt;/P&gt;&lt;P&gt;Reason I ask is because they have unpacked functionality in the feature class to feature class tool which recognizes the transfer of feature or web map services to a local file.&amp;nbsp; I have provided a copy of a script that I used to download zoning data on a monthly basis.&amp;nbsp; The beginning of my script includes deleting old shapefiles, but its not necessary. Hope this helps.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;#import arcpy module
import arcpy, os, sys
from arcpy import env
env.workspace = r"W:\MiscLayerData\Parcel\Monthly updates"
env.overwriteOutput = True

#start timer
startTime = time.perf_counter()

#Delete old CityZONING and CountyZONING shapefiles from K\GIS_UPDATE\MONTHLY folder
arcpy.management.Delete(r"K:\GIS_UPDATE\MONTHLY\CountyZONING.shp;K:\GIS_UPDATE\MONTHLY\CityZONING.shp", '')
print("old zoning data deleted from K:\GIS_UPDATE\MONTHLY folder")

#Download and copy over the City's Zoning data with ZONECLASS field to Monthly.gdb
arcpy.conversion.FeatureClassToFeatureClass("https://gis.ocalafl.org/arcgis/rest/services/OneMap/GrowthManagement/FeatureServer/7", r"K:\GIS_UPDATE\DATA\Monthly.gdb", "CityZONING", '', 'ZONECLASS "Zoning Classification" true true false 10 Text 0 0,First,#,https://gis.ocalafl.org/arcgis/rest/services/OneMap/GrowthManagement/FeatureServer/7,ZONECLASS,0,10', '')
print("City of Ocala Zoning Downloaded and copied to CityZONING in Monthly.gdb")

#Download and copy over the County's Zoning data with ZONECLASS field to Monthly.gdb
arcpy.conversion.FeatureClassToFeatureClass("https://gis.marionfl.org/public/rest/services/App/ZoningDistricts_PA/FeatureServer/0", r"K:\GIS_UPDATE\DATA\Monthly.gdb", "CountyZONING", '', 'ZONECLASS "Zoning Classification" true true false 10 Text 0 0,First,#,https://gis.marionfl.org/public/rest/services/App/ZoningDistricts_PA/FeatureServer/0,ZONECLASS,0,10', '')
print("County Zoning Downloaded and copied to CountyZONING in Monthly.gdb")
print("Monthly Zoning update completed")

#end timer
endTime = time.perf_counter()
elapsedTime = round((endTime - startTime) / 60, 2)
print("Script finished in {0} minutes".format(elapsedTime))

#provide input to stop script - uncomment input below if you need to see the script final output in the command window
input('Press ENTER to exit')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Oct 2021 14:03:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/python-download-automation/m-p/1110236#M42688</guid>
      <dc:creator>ABishop</dc:creator>
      <dc:date>2021-10-22T14:03:54Z</dc:date>
    </item>
    <item>
      <title>Re: Python Download Automation</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/python-download-automation/m-p/1110237#M42689</link>
      <description>&lt;P&gt;yes, i am calling on the instance of python from ArcGIS Pro.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Oct 2021 14:05:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/python-download-automation/m-p/1110237#M42689</guid>
      <dc:creator>DaveTenney</dc:creator>
      <dc:date>2021-10-22T14:05:05Z</dc:date>
    </item>
    <item>
      <title>Re: Python Download Automation</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/python-download-automation/m-p/1110240#M42690</link>
      <description>&lt;P&gt;Try this method... it works like a charm and you don't need credentials as long as you run it from a PC where you are logged into your account.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Oct 2021 14:06:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/python-download-automation/m-p/1110240#M42690</guid>
      <dc:creator>ABishop</dc:creator>
      <dc:date>2021-10-22T14:06:39Z</dc:date>
    </item>
    <item>
      <title>Re: Python Download Automation</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/python-download-automation/m-p/1111221#M42747</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/486546"&gt;@ABishop&lt;/a&gt;&amp;nbsp;- thank you so much that did the job!&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks!&lt;/P&gt;&lt;P&gt;Dave&lt;/P&gt;</description>
      <pubDate>Tue, 26 Oct 2021 12:56:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/python-download-automation/m-p/1111221#M42747</guid>
      <dc:creator>DaveTenney</dc:creator>
      <dc:date>2021-10-26T12:56:23Z</dc:date>
    </item>
    <item>
      <title>Re: Python Download Automation</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/python-download-automation/m-p/1111223#M42748</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/292435"&gt;@DaveTenney&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You are very welcomed!&amp;nbsp; So happy it worked out for you!&lt;/P&gt;</description>
      <pubDate>Tue, 26 Oct 2021 12:58:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/python-download-automation/m-p/1111223#M42748</guid>
      <dc:creator>ABishop</dc:creator>
      <dc:date>2021-10-26T12:58:43Z</dc:date>
    </item>
  </channel>
</rss>

