From 81da61b828e29b7745e1382dfbbaeb685dc083ef Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期二, 23 一月 2024 17:17:55 +0800
Subject: [PATCH] 抖音转链修改

---
 fanli/src/main/java/com/yeshi/fanli/util/goods/douyin/DYUtil.java |   63 +++++++++++++++++--------------
 1 files changed, 34 insertions(+), 29 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/util/goods/douyin/DYUtil.java b/fanli/src/main/java/com/yeshi/fanli/util/goods/douyin/DYUtil.java
index 757fe80..2d0f9ca 100644
--- a/fanli/src/main/java/com/yeshi/fanli/util/goods/douyin/DYUtil.java
+++ b/fanli/src/main/java/com/yeshi/fanli/util/goods/douyin/DYUtil.java
@@ -131,35 +131,40 @@
             return null;
         }
 
-        HttpClient client = new HttpClient();
-        client.getHttpConnectionManager().getParams().setConnectionTimeout(5000);
-        PostMethod pm = new PostMethod(url);
-        try {
-            client.executeMethod(pm);
-            Header header = pm.getResponseHeader("location");
-            if (header == null) {
-                return null;
-            }
-            if (header.getValue() == null) {
-                return null;
-            }
-            if (!header.getValue().contains("detail/index.html")) {
-                return null;
-            }
-            String value = URLDecoder.decode(header.getValue(), "UTF-8");
-
-            String[] results = value.split("&");
-            for (String r : results) {
-                if (!r.contains("product_id=")) {
-                    continue;
-                }
-                return r.split("=")[1].trim();
-            }
-        } catch (IOException e) {
-            e.printStackTrace();
-        }
-
-        return null;
+        String id = CSJCPSApiUtil.parseProductId(url);
+        return id;
+//
+//        HttpClient client = new HttpClient();
+//        client.getHttpConnectionManager().getParams().setConnectionTimeout(5000);
+//        PostMethod pm = new PostMethod(url);
+//        try {
+//            client.executeMethod(pm);
+//            Header header = pm.getResponseHeader("location");
+//            if (header == null) {
+//                return null;
+//            }
+//            if (header.getValue() == null) {
+//                return null;
+//            }
+//            if (!header.getValue().contains("detail/index.html")) {
+//                return null;
+//            }
+//            String value = URLDecoder.decode(header.getValue(), "UTF-8");
+//            value = value.split("\\?")[1];
+//            String[] results = value.split("&");
+//            for (String r : results) {
+//                String key = r.split("=")[0].trim();
+//                String val = r.split("=")[1];
+//                if (!key.equalsIgnoreCase("product_id") && !key.equalsIgnoreCase("id")) {
+//                    continue;
+//                }
+//                return val.trim();
+//            }
+//        } catch (IOException e) {
+//            e.printStackTrace();
+//        }
+//
+//        return null;
     }
 
     public static BigDecimal getPrice(int money) {

--
Gitblit v1.8.0