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數(shù)量
? ? print("總notebook數(shù)量", notebook_num)
# 清除notebook輸出的結(jié)果
? ? 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*"*")