You can create a GPService using arcpy.CopyFeatures_management(Input_Features, Output_Shapefile) to create a shapefile from a GPFeatureRecordSetLayer which you can construct it using map/feature service layer to just specify the URL with any query.Hope this helps.
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.