38 lines
979 B
Python
38 lines
979 B
Python
|
|
|
||
|
|
def parse_sql_res(sql_res: list[dict]):
|
||
|
|
'''
|
||
|
|
解析sql_res
|
||
|
|
'''
|
||
|
|
parsed_data = sql_res[0]["data"][0]["save_scrape_result"]
|
||
|
|
return parsed_data
|
||
|
|
|
||
|
|
def main(sql_res: list[dict], count_completed: float, count_remaining: float, count_error: float):
|
||
|
|
|
||
|
|
parsed_data = parse_sql_res(sql_res)
|
||
|
|
if parsed_data["status"] == "success":
|
||
|
|
count_completed += 1
|
||
|
|
count_remaining -= 1
|
||
|
|
else:
|
||
|
|
count_error += 1
|
||
|
|
|
||
|
|
return {
|
||
|
|
"result":{
|
||
|
|
"count_completed": count_completed,
|
||
|
|
"count_remaining": count_remaining,
|
||
|
|
"count_error": count_error,
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
if __name__ == "__main__":
|
||
|
|
import json
|
||
|
|
with open(r"anyscript\wiki_crawler\regard.json", "r", encoding="utf-8") as f:
|
||
|
|
data = json.load(f)
|
||
|
|
res = main(
|
||
|
|
sql_res=data["sql_res"],
|
||
|
|
count_completed=data["count_completed"],
|
||
|
|
count_remaining=data["count_remaining"],
|
||
|
|
count_error=data["count_error"],
|
||
|
|
)
|
||
|
|
print(res)
|