Hello, I created a script to find the latest uploaded items on ArcGIS Online using ArcGIS API for python.
There are no errors but it does not find anything. I search for items uploaded in last 7, 30 or even 100 days.
It finds few items if I search from 2009 till now but even then I don't think it shows everything.
Did I miss something? Do I need to format query differently? Out of ideas...
Code:
from arcgis.gis import GIS
gis = GIS("http://arcgisonline.maps.arcgis.com", "username", "password", proxy_host = "example", proxy_port = 0000)
# how far back does the search go? user input
input_days = input("how many days back do you want to search? ")
# based on days, that user has entered, calculate the date to start the search from in unix time, in seconds as per query format requirements
import time
now = time.time()
# converting input to integer, then to seconds, then calculating date from which items where uploaded to unix time
days = int(input_days)
days_in_seconds = days*24*60*60
dateFrom_s = now - days_in_seconds
# function to format unix time in seconds to the format required
def timeQuery(time_in_seconds):
# convert time to milliseconds, then to interger to remove everything after point, then convert to string and add 6x0
return ('000000'+str(int(time_in_seconds*1000)))
nowQ = timeQuery(now)
beforeQ = timeQuery(dateFrom_s)
print(beforeQ)
print(nowQ)
search_result = gis.content.search(query = "uploaded: [beforeQ TO nowQ]")
#search_result = gis.content.search(query = "*")
# some date in 2009 in unix time, ms, and six zeros at the front as per query requirement 0000001259692864000
search_result2 = gis.content.search(query = "uploaded: [0000001259692864000 TO 0000001542676158153]")
#search_result = gis.content.search(query = "*")
print(search_result)
print(search_result2)