代码拉取完成,页面将自动刷新
# import re
#
# import jsonpath
# import yaml
#
# return_json = {'folders': [
# {'folder_id': 'folder.qunxUVQKjZE99_KsvlH1LA', 'folder_name': 'helloworld', 'is_creator': True,
# 'created_at': '2022-04-28T12:19:17.350876904Z', 'last_edit_at': '2022-04-28T13:33:03.782216276Z',
# 'favorite': False}, {'folder_id': 'folder.sVY98zAn5xk3xiNFxI4b0K', 'folder_name': 'hello', 'is_creator': True,
# 'created_at': '2022-04-28T13:07:39.527428092Z',
# 'last_edit_at': '2022-04-28T13:07:39.527428092Z', 'favorite': False},
# {'folder_id': 'folder.U7kwOvZhTjPjOpe7-u5VyL', 'folder_name': 'hello', 'is_creator': True,
# 'created_at': '2022-04-28T13:10:15.463068441Z', 'last_edit_at': '2022-04-28T13:10:15.463068441Z',
# 'favorite': False}, {'folder_id': 'folder.wLg5tLlVc5bDOUPZoM9lna', 'folder_name': 'hello', 'is_creator': True,
# 'created_at': '2022-04-28T13:16:42.72617247Z',
# 'last_edit_at': '2022-04-28T13:16:42.72617247Z', 'favorite': False},
# {'folder_id': 'folder.OmupKjc5xQbVk-C-Cor0_9', 'folder_name': 'hello', 'is_creator': True,
# 'created_at': '2022-04-28T13:19:34.218893237Z', 'last_edit_at': '2022-04-28T13:19:34.218893237Z',
# 'favorite': False}, {'folder_id': 'folder.yjOw7oHNr_ZTxGYoD65N9l', 'folder_name': 'hello', 'is_creator': True,
# 'created_at': '2022-04-28T13:33:03.090030529Z',
# 'last_edit_at': '2022-04-28T13:33:03.090030529Z', 'favorite': False},
# {'folder_id': 'folder.F4ffinZuds4ohlunEorYD2', 'folder_name': 'hello', 'is_creator': True,
# 'created_at': '2022-04-28T13:39:06.031684501Z', 'last_edit_at': '2022-04-28T13:39:06.031684501Z',
# 'favorite': False}]}
#
# with open(r"C:\Users\Fly\Desktop\api_test\extract.yaml", encoding='utf-8') as f:
# value = yaml.load(f, Loader=yaml.FullLoader)
# print(value["folder_id_list"])
#
#
# import json
# # aa = str({"folder_ids": ['folder.wLg5tLlVc5bDOUPZoM9lna', 'folder.t-wPVvvsCcGe4JAbIfyThR', 'folder.L4aju2Agfu-5VPIySgIePF', 'folder.KZTyFcMlr_qBGsRmOANWwD', 'folder{"folder_ids": ['folder.wLg5tLlVc5bDOUPZoM9lna', 'folder.t-wPVvvsCcGe4JAbIfyThR', 'folder.L4aju2Agfu-5VPIySgIePF', 'folder.KZTyFcMlr_qBGsRmOANWwD', 'folder.QMzE8i8o1IG21n1ZYBCFpy', 'folder.2v__f_U0G4EPGuOSl3Kv6Q']}"
# aa = str({'folder_ids': ['folder.wLg5tLlVc5bDOUPZoM9lna', 'folder.t-wPVvvsCcGe4JAbIfyThR', 'folder.L4aju2Agfu-5VPIySgIePF', 'folder.KZTyFcMlr_qBGsRmOANWwD', 'folder.QMzE8i8o1IG21n1ZYBCFpy', 'folder.2v__f_U0G4EPGuOSl3Kv6Q']})
# res = json.loads(aa)
# print(res)
import yaml
def write_extract_yaml(data):
"""
Write key-value pairs to extract.yaml
:param data: like {key:value}
:return: None
"""
flag = False
with open(r"C:\Users\Fly\Desktop\api_test\extract.yaml", encoding='utf-8') as f:
value = yaml.load(f, Loader=yaml.FullLoader)
for item in list(data.keys()):
if item in value.keys():
flag = True
break
if not flag:
with open(r"C:\Users\Fly\Desktop\api_test\extract.yaml", encoding='utf-8', mode="a") as f:
yaml.dump(data=data, stream=f, allow_unicode=True)
write_extract_yaml({"comment_id": "234455"})
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。