获取1688链接的正则表达式

20230922-ljl-fixBug
qiushengjie 1 year ago
parent bd9a17e2b3
commit c0d614431d

File diff suppressed because it is too large Load Diff

@ -0,0 +1,22 @@
package com.ms.test;
import com.alibaba.fastjson.JSON;
import com.ms.api.common.StrObjMap;
import com.ms.api.consts.MoveConst;
import com.ms.api.dto.move.MoveProductDTO;
import java.util.LinkedList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class ParseUrlTest {
public static void main(String[] args) {
String url = "https://detail.1688.com/offer/1170150484.html?spm=a2638t.27033214.reofferlist.3.3836436cs3Sfb7&cosite=-&ilike_session=be0662f0477043b5a18fa1c387874546&tracelog=p4p&_p_isad=1&clickid=be0662f0477043b5a18fa1c387874546&sessionid=83661dcc6244135f10a5399fceda54a1";
Pattern pattern = Pattern.compile("(.*\\.1688\\.com\\/(?:offer|pic)\\/|caigou\\.1688\\.com\\/detail\\/)(\\d+).(htm|html)", Pattern.CASE_INSENSITIVE);
Matcher matcher = pattern.matcher(url);
if (matcher.find()) {
System.out.println(matcher.group(2)); // 输出: 1170150484
}
}
}
Loading…
Cancel
Save