Home > other >  Since the loop results summary?
Since the loop results summary?

Time:04-24

By getting to the next page next_cursor, since the circulation function, obtain a list to get the list, but only the first set of data returned by the data, how to get to the list of list summary to the result?



 
The import requests
The import json
The import time
Import a datetime

# access token
Def getAccess () :
Url="https://oapi.dingtalk.com/gettoken? Appkey={0} & amp; Appsecret={1} ". The format (app_key, app_secret)
Jo=json. Loads (requests. Get (url). The text)
Return Jo [' access_token ']

# get approval ID
Def getSpID (token, cursor) :
Url="https://oapi.dingtalk.com/topapi/processinstance/listids? Access_token={0} & amp; Process_code={1} & amp; Start_time={2} & amp; Cursor={3} ". The format (token, process_code, start_time, cursor)
# print (url)
Dp=json. Loads (requests. Get (url). The text)
# print (dp)
# print (dp [' result '])
Li=dp [' result '] [' list ']
Print (li)
Try:
Next_cursor=dp [' result '] [' next_cursor]
Print (next_cursor)
If next_cursor & gt; 0:
GetSpID (token, next_cursor)
Except KeyError:
Print (' no next ')
Return li

If __name__=="__main__ ':

App_key='XXX'
App_secret='XXX'
Agent_id='XXX'
Corp_id='XXX'
Process_code='XXX'

# the current date
# t1=datetime. Datetime. Now (). The strftime (' % % Y - m - % d 00:00:00 ')
T1='2021-04-22 00:00:00'
# print (t1)
# to second grade timestamp
T2=time. Mktime (time. Strptime (t1, '% % Y - m - H: % d % % m: % S'))
# print (start_time)
# to millisecond
Start_time=STR (t2 * 1000). The split (". "[0])


# token
Token=getAccess ()
# print (token)

Process_code=getProcess_code (token, name)
# print (process_code)

Start_cursor=0
Dp=getSpID (token, start_cursor)
Print (' results as follows: 'dp)

  • Related