home0927
This commit is contained in:
@@ -209,19 +209,23 @@ class Sinopec_ewcc(object):
|
|||||||
def send_message(self):
|
def send_message(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def query_car_info(self, plate_number=None, phone_number=None, additional_info={}):
|
def query_car_info(self, plate_number=None, phone_number=None, result_list=None):
|
||||||
"""查询车辆信息
|
"""查询车辆信息
|
||||||
Args:
|
Args:
|
||||||
plate_number: 车牌号
|
plate_number: 车牌号
|
||||||
phone_number: 手机号
|
phone_number: 手机号
|
||||||
additional_info: 附加查询信息
|
result_list: 用于存储查询结果的列表(通过参数返回)
|
||||||
Returns:
|
Returns:
|
||||||
list: 查询到的车辆信息列表
|
bool: 查询是否成功,成功返回True,失败返回False
|
||||||
"""
|
"""
|
||||||
# 参数校验
|
# 参数校验
|
||||||
if not plate_number and not phone_number:
|
if not plate_number and not phone_number:
|
||||||
logger.warning("车牌号和手机号至少需要提供一个")
|
logger.warning("车牌号和手机号至少需要提供一个")
|
||||||
return []
|
return False
|
||||||
|
|
||||||
|
# 初始化结果列表
|
||||||
|
if result_list is None:
|
||||||
|
result_list = []
|
||||||
|
|
||||||
logger.info(f"查询车牌号: {plate_number} 电话:{phone_number}")
|
logger.info(f"查询车牌号: {plate_number} 电话:{phone_number}")
|
||||||
|
|
||||||
@@ -257,11 +261,10 @@ class Sinopec_ewcc(object):
|
|||||||
DataPacket = myframe.listen.wait(timeout=10) # 添加超时参数
|
DataPacket = myframe.listen.wait(timeout=10) # 添加超时参数
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"等待查询响应超时: {str(e)}")
|
logger.error(f"等待查询响应超时: {str(e)}")
|
||||||
return []
|
return False
|
||||||
finally:
|
finally:
|
||||||
myframe.listen.stop()
|
myframe.listen.stop()
|
||||||
|
|
||||||
result_list = []
|
|
||||||
if DataPacket and hasattr(DataPacket, 'response') and hasattr(DataPacket.response, 'body'):
|
if DataPacket and hasattr(DataPacket, 'response') and hasattr(DataPacket.response, 'body'):
|
||||||
if DataPacket.response.body.get('success'):
|
if DataPacket.response.body.get('success'):
|
||||||
total_num = DataPacket.response.body['data'].get('total', 0)
|
total_num = DataPacket.response.body['data'].get('total', 0)
|
||||||
@@ -284,11 +287,11 @@ class Sinopec_ewcc(object):
|
|||||||
finally:
|
finally:
|
||||||
self.tab.listen.stop()
|
self.tab.listen.stop()
|
||||||
|
|
||||||
return result_list
|
return True
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"查询车辆信息时发生异常: {str(e)}")
|
logger.error(f"查询车辆信息时发生异常: {str(e)}")
|
||||||
return []
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+3
-2
@@ -184,7 +184,7 @@ def main():
|
|||||||
time.sleep(30)
|
time.sleep(30)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# 只留浏览器cookies
|
# 保留浏览器cookies
|
||||||
save_param4( ewcc.tab.cookies())
|
save_param4( ewcc.tab.cookies())
|
||||||
|
|
||||||
# 获取待处理查询
|
# 获取待处理查询
|
||||||
@@ -193,7 +193,8 @@ def main():
|
|||||||
# 处理每条查询
|
# 处理每条查询
|
||||||
for query in pending_queries:
|
for query in pending_queries:
|
||||||
# 处理查询数据
|
# 处理查询数据
|
||||||
rtn_cars_info=ewcc.query_car_info(query['plate_number'],query['phone'])
|
rtn_cars_info=[]
|
||||||
|
if ewcc.query_car_info(query['plate_number'],query['phone'],rtn_cars_info) :
|
||||||
# 更新查询结果
|
# 更新查询结果
|
||||||
logger.info(f"查询结果数量: {len(rtn_cars_info)}")
|
logger.info(f"查询结果数量: {len(rtn_cars_info)}")
|
||||||
update_query_result(query['id'], len(rtn_cars_info), rtn_cars_info)
|
update_query_result(query['id'], len(rtn_cars_info), rtn_cars_info)
|
||||||
|
|||||||
Reference in New Issue
Block a user