I got this snippet from a friend.
I didn't try it.
*********************************************************************************************************************************************
import
arcpy
# Modify the following variables:
# URL to your service, where clause, fields and token if applicable
baseURL=
"http://sampleserver6.arcgisonline.com/arcgis/rest/services/PoolPermits/FeatureServer/1/query"
where =
'1=1'
fields ='apn, address, pool_permit'
token =
''
#The above variables construct the query
query =
"?where={}&outFields={}&returnGeometry=true&f=json&token={}".format(where, fields, token)
# See http://services1.arcgis.com/help/index.html?fsQuery.html for more info on FS-Query
fsURL =
baseURL +
query
fs =
arcpy.FeatureSet()
fs.load(fsURL)
arcpy.CopyFeatures_management(fs, r"c:\local\data.gdb\permits")
**********************************************************************************************************************************************
Regards,
Rami