import json
import urllib3
base_url_list = ['http://192.168.19.137:8899','http://192.168.19.137:8899']
for base_urlin base_url_list:
http = urllib3.PoolManager(timeout=3.0,retries=False)
url ='{base_url}/api/notebook/'.format(base_url=base_url)
try:
r = http.request('GET', url)
except urllib3.exceptions.NewConnectionError:
print('Connection failed.')
# print(r.data.decode())
notebook_list = json.loads(r.data.decode()).get('body')
notebook_num =len(notebook_list)
# 获取notebook数量
print("总notebook数量", notebook_num)
# 清除notebook输出的结果
for iin range(notebook_num):
try:
noteid = notebook_list[i].get("id")
notepath = notebook_list[i].get("path")
print(noteid, notepath)
except:
noteid =""
target_url ="{base_url}/api/notebook/{i}/clear".format(base_url=base_url, i=noteid)
try:
res_clear = r = http.request('PUT', target_url)
print(res_clear.data.decode())
except urllib3.exceptions.NewConnectionError:
print('Connection failed.')
print(base_url,"处理完毕")
print(50*"*")