实现获取访客图片接口

This commit is contained in:
haotianmingyue 2025-09-18 16:57:50 +08:00
parent 1f7dd0393c
commit 4ee2379efa
2 changed files with 11 additions and 4 deletions

View File

@ -117,7 +117,8 @@ if __name__ == '__main__':
# asyncio.run(face_group_1vN_search_service(image_path))
#asyncio.run(face_picture_check(image_path))
asyncio.run(query_visitor_record())
#asyncio.run(query_visitor_record())
asyncio.run(query_visitor_record_pictures_service("80890167-b8d4-4e33-af35-94db87c90816"
, "/pic?0de900=71f0ip-4eo881-342*fo1=9=8522*4l5373169147*1t1=0*0ps==418b*=6127*38da35a12-8338cd-9*l168od0f1f1=002"))
#asyncio.run(door_online_status_service(["d4a610b6554d4544bc35dd3138f128b0"]))

View File

@ -98,6 +98,12 @@ class HaikangUtil:
response = await client.request(
method, url, headers=headers, content=body, timeout=60
)
if response.status_code in (301, 302, 303, 307, 308):
location = response.headers.get("Location")
# 可能需要处理成 GET 请求或保留原方法
response = await client.get(location, headers=headers)
response.raise_for_status()
# if response.status_code >= 400:
# logger.error(f"发送请求失败: {url} , {response.status_code} {response.text}")
@ -482,9 +488,9 @@ class HaikangUtil:
"POST", url, body_json, HaiKangConfig.HAIKANG_AK, HaiKangConfig.HAIKANG_SK
)
back = await cls.send_request("POST", url, headers, body_json)
back = await cls.send_request("POST", url, headers, body_json, False)
with open("person.jpg", 'wb') as f:
for chunk in back.iter_content(chunk_size=8192):
for chunk in back.iter_bytes(chunk_size=8192):
if chunk: # 忽略 keep-alive 的空 chunk
f.write(chunk)