Files
wiki_crawler/nodes/iteration_output.py

26 lines
804 B
Python
Raw Permalink Normal View History

2025-12-22 22:50:07 +08:00
def check_status(status_code: float, body: str):
'''
检查状态码和约定的返回值
'''
if status_code != 200:
raise Exception(f"注册任务失败,状态码:{status_code}")
if "code" not in body or body["code"] != 1:
raise Exception(f"注册任务失败,返回值:{body}")
def main(iteration_output: list[dict], status_code: float, body: str):
2025-12-22 22:33:18 +08:00
'''
迭代器运行结果记录
iteration_output: 迭代器运行结果记录
status_code: 从URL获取的响应状态码
2025-12-22 22:50:07 +08:00
body: 从URL获取的响应体
2025-12-22 22:33:18 +08:00
'''
2025-12-22 22:50:07 +08:00
try:
check_status(status_code, body)
data = body["data"]
iteration_output.append(data)
except Exception as e:
raise e
2025-12-22 22:33:18 +08:00
return {
2025-12-22 22:50:07 +08:00
"iteration_output": iteration_output,
2025-12-22 22:33:18 +08:00
}