diff --git a/src/main/java/com/tem/bocai/util/LotteryWebMagicCrawler.java b/src/main/java/com/tem/bocai/util/LotteryWebMagicCrawler.java index adb361f..08a0e37 100644 --- a/src/main/java/com/tem/bocai/util/LotteryWebMagicCrawler.java +++ b/src/main/java/com/tem/bocai/util/LotteryWebMagicCrawler.java @@ -123,7 +123,7 @@ public class LotteryWebMagicCrawler implements PageProcessor { * @param htmlContent 爬取到的HTML文本内容 * @return 解析后的结构化数据列表 */ - public static List> parseLotteryHtml(String htmlContent) { + public List> parseLotteryHtml(String htmlContent) { List> resultList = new ArrayList<>(); // 初始化Jsoup解析器 @@ -242,7 +242,7 @@ public class LotteryWebMagicCrawler implements PageProcessor { return resultList; } - public static void writeToJsonFile(List> resultList) { + public void writeToJsonFile(List> resultList) { try { // 创建 ObjectMapper 实例 ObjectMapper objectMapper = new ObjectMapper(); @@ -251,7 +251,7 @@ public class LotteryWebMagicCrawler implements PageProcessor { objectMapper.enable(SerializationFeature.INDENT_OUTPUT); // 定义输出目录 - String directoryPath = "PyModel/current_data"; // 项目根目录下的 output/json 文件夹 + String directoryPath = path+"/current_data"; // 项目根目录下的 output/json 文件夹 // 使用年月日作为文件名(格式:result_yyyyMMdd.json) SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");