人民日报增加域
This commit is contained in:
@@ -10,8 +10,8 @@ import json
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
# Add parent directory to path to import crawler
|
||||
sys.path.insert(0, str(Path(__file__).parent.parent))
|
||||
# Add project root directory to path to import crawler
|
||||
sys.path.insert(0, str(Path(__file__).parent.parent.parent))
|
||||
|
||||
from crawler.rmrb.RmrbCrawler import RmrbCrawler
|
||||
from loguru import logger
|
||||
@@ -89,11 +89,13 @@ def main():
|
||||
"data": None,
|
||||
"dataList": [item.model_dump() for item in result.dataList] if result.dataList else []
|
||||
}
|
||||
result = None
|
||||
with open("F:\Project\schoolNews\schoolNewsCrawler\output\output.json", "r", encoding="utf-8") as f:
|
||||
result = json.load(f)
|
||||
print(result)
|
||||
output = result
|
||||
# result = None
|
||||
# with open("F:\Project\schoolNews\schoolNewsCrawler\output\output.json", "r", encoding="utf-8") as f:
|
||||
# result = json.load(f)
|
||||
# print(result)
|
||||
# output = result
|
||||
|
||||
|
||||
if output_file:
|
||||
output_path = Path(output_file)
|
||||
output_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
@@ -101,13 +103,10 @@ def main():
|
||||
json.dump(output, f, ensure_ascii=False, indent=2)
|
||||
logger.info(f"结果已保存到: {output_file}")
|
||||
|
||||
|
||||
crawler.close()
|
||||
# sys.exit(0 if result.success else 1)
|
||||
sys.exit(0 if result.success else 1)
|
||||
# print(json.dumps(output, ensure_ascii=False, indent=2))
|
||||
|
||||
sys.exit(0 if result["success"] else 1)
|
||||
|
||||
# sys.exit(0 if result["success"] else 1)
|
||||
except Exception as e:
|
||||
logger.error(f"执行失败: {str(e)}")
|
||||
error_output = {
|
||||
|
||||
Reference in New Issue
Block a user