| | |
| | | |
| | | public static String parseGoodsIdByUrl(String url) { |
| | | try { |
| | | if (isVIPShopLink(url) && (url.contains("detail-") || url.contains("product-"))) { |
| | | if (isVIPShopLink(url)) { |
| | | if (url.contains("detail-") || url.contains("product-")) { |
| | | String preUrl = url.split("\\?")[0]; |
| | | String goodsId = preUrl.split("-")[preUrl.split("-").length - 1].replace(".html", "").replace(".htm", |
| | | ""); |
| | | if (NumberUtil.isNumeric(goodsId)) |
| | | return goodsId; |
| | | } else { |
| | | if (url.split("\\?").length > 1) { |
| | | String param = url.split("\\?")[1]; |
| | | String[] params = param.split("&"); |
| | | for (String p : params) { |
| | | String[] ps = p.split("="); |
| | | if (ps.length > 1 && ps[0].trim().equalsIgnoreCase("goodsId")) { |
| | | return ps[1].trim(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | } catch (Exception e) { |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | |
| | | System.out.print(parseGoodsIdByUrl("https://mst.vip.com/x6M88WQc9Abq5h0CHNg1uw.php?wapid=mst_100099181&_src=mst&extra_banner=115099181&nova=1&nova_platform=1&mst_page_type=guide&goodsId=6920553939593155215&brandId=1712199535&actType=normal&launchId=&nmsns=shop_android-9.10.2-link&nst=product&nsbc=&nct=link&ncid=9ab423d2-932f-3916-b913-4ddf57e809ed&nabtid=13&nuid=59508964&nchl_param=share:9ab423d2-932f-3916-b913-4ddf57e809ed:1697182347995&mars_cid_a=9ab423d2-932f-3916-b913-4ddf57e809ed&chl_type=share")); |
| | | } |
| | | } |
| | | |
| | | |