1
This commit is contained in:
@@ -24,6 +24,8 @@ public class LineReportParser {
|
||||
private static final Pattern UJD_AND_PRICE_PATTERN = Pattern.compile("(?i)https?://[^\\s]*u\\.jd\\.com/[^\\s]+\\s+\\b(\\d{1,6}(?:\\.\\d{1,2})?)\\b");
|
||||
// 行内价格通用匹配(支持¥/💰/纯数字),用于邻近行回溯
|
||||
private static final Pattern PRICE_NEAR_PATTERN = Pattern.compile("[¥💰]?\\s*([0-9]{1,6}(?:\\.[0-9]{1,2})?)");
|
||||
// “不高于”价格匹配
|
||||
private static final Pattern NOT_HIGHER_PATTERN = Pattern.compile("不高于\\s*([0-9]{1,6}(?:\\.[0-9]{1,2})?)");
|
||||
|
||||
/**
|
||||
* 从线报消息中提取所有京东链接
|
||||
@@ -126,6 +128,12 @@ public class LineReportParser {
|
||||
price = parsePrice(rich.group(1));
|
||||
break;
|
||||
}
|
||||
// 其次匹配“不高于 xxxx”
|
||||
Matcher nh = NOT_HIGHER_PATTERN.matcher(prev);
|
||||
if (nh.find()) {
|
||||
price = parsePrice(nh.group(1));
|
||||
break;
|
||||
}
|
||||
Matcher any = PRICE_NEAR_PATTERN.matcher(prev);
|
||||
if (any.find()) {
|
||||
price = parsePrice(any.group(1));
|
||||
|
||||
Reference in New Issue
Block a user