1.参数提取异常处理

This commit is contained in:
mojin 2023-03-21 21:05:00 +08:00
parent 4148468ba4
commit bff89cdb1c
1 changed files with 9 additions and 1 deletions

View File

@ -28,11 +28,19 @@ class ExchangeData():
@classmethod
def Extract(cls,response,josn_path_dic):
josn_path_dic = cls.rep_expr(josn_path_dic, return_type='srt')
#josn_path_dic = cls.rep_expr(josn_path_dic, return_type='srt')
try:
josn_path_dic = cls.rep_expr(josn_path_dic, return_type='srt')
eval(josn_path_dic)
except:
pass
if josn_path_dic!="" and eval(josn_path_dic)!={}:
for k, v in eval(josn_path_dic).items():
v = cls.rep_expr(v, return_type='no')
k = cls.rep_expr(k, return_type='no')
try:
jsonpath_v=jsonpath.jsonpath(response, v)
cls.extra_pool[k] = jsonpath_v[random.randint(0,len(jsonpath_v)-1)] #如拿到是多个数据,列表,随机取其中一个