【发布时间】:2020-01-08 04:19:20
【问题描述】:
下面是我用来从存储库中获取值的代码。在这里,我只给出了第 1 页的数据。但是如何使用循环从该存储库中存在的所有页面获取数据。并且这些数据将再次使用 Post 方法发布回另一个 URL。
import requests
import json
headers = {
'Content-Type': 'application/json, Accept: application/json',
}
params = (
('dql', 'select u.user_name as USER_NAME,u.user_login_name as USER_LOGIN,u.default_folder as
DEFAULT_FOLDER_PATH, u.last_login_utc_time as USER_LAST_LOGIN, u.user_os_domain as
USER_OS_DOMAIN,u.user_login_domain as USER_LOGIN_DOMAIN,u.user_state as USER_STATE,f.object_name as
DEFAULT_FOLDER_NAME,f.r_creation_date as DEFAULT_FOLDER_CREATION_DATE,f.r_modify_date as
DEFAULT_FOLDER_MODIFY_DATE from dm_user u, dm_folder f where u.default_folder = f.r_folder_path
enable(ROW_BASED)'),
('items-per-page', '2'),
('page', '1'),
)
def requestcall():
myResponse = requests.get('https://1.1.1.1/rest/repositories/hhdht@@', headers=headers,
params=params, verify=False, auth=('@@@@@@', '#######'))
print(myResponse.status_code)
# For successful API call, response code will be 200 (OK)
if myResponse.ok:
# extracting data in json format
data = myResponse.json()
return data
requestcall()
【问题讨论】: