新增输出节点
This commit is contained in:
14
nodes/output.py
Normal file
14
nodes/output.py
Normal file
@@ -0,0 +1,14 @@
|
||||
|
||||
def main(task_id: float, is_new_task, add_urls_result: list[dict], urls: list[str], output: list[dict]):
|
||||
|
||||
# 组建返回结果
|
||||
output = {
|
||||
"task_id": task_id,
|
||||
"is_new_task": is_new_task,
|
||||
"add_urls_result": add_urls_result,
|
||||
"process_urls": urls,
|
||||
"iteration_result": output,
|
||||
}
|
||||
return {
|
||||
"output": output,
|
||||
}
|
||||
20
nodes/parse_save_urls.py
Normal file
20
nodes/parse_save_urls.py
Normal file
@@ -0,0 +1,20 @@
|
||||
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(status_code: float, body: str):
|
||||
try:
|
||||
check_status(status_code, body)
|
||||
except Exception as e:
|
||||
raise e
|
||||
|
||||
urls_result = body["data"]
|
||||
|
||||
return {
|
||||
"add_urls_result": urls_result
|
||||
}
|
||||
Reference in New Issue
Block a user