1
This commit is contained in:
@@ -144,6 +144,33 @@ public class LineReportParser {
|
||||
result.put(url, price);
|
||||
}
|
||||
}
|
||||
if (!result.containsKey(url)) {
|
||||
// 前向查找:向下最多2行寻找价格
|
||||
Double fprice = null;
|
||||
for (int k = 1; k <= 2 && i + k < lines.length; k++) {
|
||||
String next = lines[i + k];
|
||||
if (next == null || next.isEmpty()) break; // 空行视为分段
|
||||
// 优先匹配包含💰或¥的价格
|
||||
Matcher richN = Pattern.compile("[¥💰]\\s*([0-9]{1,6}(?:\\.[0-9]{1,2})?)").matcher(next);
|
||||
if (richN.find()) {
|
||||
fprice = parsePrice(richN.group(1));
|
||||
break;
|
||||
}
|
||||
// 其次匹配“不高于 xxxx”
|
||||
Matcher nhN = NOT_HIGHER_PATTERN.matcher(next);
|
||||
if (nhN.find()) {
|
||||
fprice = parsePrice(nhN.group(1));
|
||||
break;
|
||||
}
|
||||
Matcher anyN = PRICE_NEAR_PATTERN.matcher(next);
|
||||
if (anyN.find()) {
|
||||
fprice = parsePrice(anyN.group(1));
|
||||
}
|
||||
}
|
||||
if (fprice != null) {
|
||||
result.put(url, fprice);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user