diff --git a/src/main/java/com/tem/bocai/util/CompletedTodayCrawler.java b/src/main/java/com/tem/bocai/util/CompletedTodayCrawler.java index 63ef2a2..2152c3a 100644 --- a/src/main/java/com/tem/bocai/util/CompletedTodayCrawler.java +++ b/src/main/java/com/tem/bocai/util/CompletedTodayCrawler.java @@ -262,20 +262,35 @@ public class CompletedTodayCrawler implements PageProcessor { if (resultStr == null) { return "未知"; } - - if (resultStr.contains("赢") || resultStr.contains("+")) { + // 1. 首先解析数字金额 + Double amount = parseNumeric(resultStr); + // 方法2:通过数字正负判断 + if (amount > 0) { return "赢"; - } else if (resultStr.contains("输") || resultStr.contains("-")) { + } else if (amount < 0) { return "输"; - } else if (resultStr.contains("和") || resultStr.contains("0")) { - return "和"; - } else if (resultStr.contains("取消")) { - return "取消"; } else { return "未知"; } } + /** + * 解析数值 + */ + private Double parseNumeric(String numericStr) { + try { + if (numericStr == null || numericStr.isEmpty()) { + return 0.0; + } + + // 移除非数字字符(保留小数点和负号) + String cleaned = numericStr.replaceAll("[^\\d.-]", ""); + return cleaned.isEmpty() ? 0.0 : Double.parseDouble(cleaned); + } catch (Exception e) { + return 0.0; + } + } + /** * 解析结果金额 */