From 81a2c8e297787cc7dc405d6db4972cb917cd80b5 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期五, 17 一月 2020 16:50:57 +0800
Subject: [PATCH] 无用代码删除,单品分享接口修改

---
 utils/src/main/java/org/yeshi/utils/HttpUtil.java |   33 +++++++++++++++++++++++++--------
 1 files changed, 25 insertions(+), 8 deletions(-)

diff --git a/utils/src/main/java/org/yeshi/utils/HttpUtil.java b/utils/src/main/java/org/yeshi/utils/HttpUtil.java
index 8d4179b..99c6035 100644
--- a/utils/src/main/java/org/yeshi/utils/HttpUtil.java
+++ b/utils/src/main/java/org/yeshi/utils/HttpUtil.java
@@ -10,8 +10,12 @@
 import java.net.URL;
 import java.net.URLEncoder;
 import java.security.KeyStore;
+import java.util.ArrayList;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 import javax.net.ssl.SSLContext;
 
@@ -47,6 +51,21 @@
 import net.sf.json.JSONObject;
 
 public class HttpUtil {
+
+	public static List<String> getUrlListFromText(String text) {
+		List<String> urlList = new ArrayList<String>();
+		// 閾炬帴
+		String URL_REGEX = "(((http|https)://)|(www\\.))[a-zA-Z0-9\\._-]+\\.[a-zA-Z]{2,6}(:[0-9]{1,4})?(/[a-zA-Z0-9\\&%_\\./-~-]*)?";
+		Pattern p = Pattern.compile(URL_REGEX);
+		Matcher matcher = p.matcher(text);
+		while (matcher.find()) {
+			String url = matcher.group();
+			if (!StringUtil.isNullOrEmpty(url)) {
+				urlList.add(url);
+			}
+		}
+		return urlList;
+	}
 
 	public static String getHost(String host) {
 		try {
@@ -473,13 +492,13 @@
 		}
 		return "";
 	}
-	
+
 	@SuppressWarnings("deprecation")
-	public static String post(String url, String entity,String charset) {
+	public static String post(String url, String entity, String charset) {
 		HttpClient client = new HttpClient();
 		PostMethod method = new PostMethod(url);
-		method.addRequestHeader("Content-Type", "text/html;charset="+charset);
-		method.setRequestHeader("Content-Type", "text/html;charset="+charset);
+		method.addRequestHeader("Content-Type", "text/html;charset=" + charset);
+		method.setRequestHeader("Content-Type", "text/html;charset=" + charset);
 		method.setRequestBody(entity);
 		try {
 			client.executeMethod(method);
@@ -601,9 +620,7 @@
 
 		return result;
 	}
-	
-	
-	
+
 	/**
 	 * 鑾峰彇post杩斿洖location
 	 * @param url
@@ -614,7 +631,7 @@
 		PostMethod method = new PostMethod(url);
 		try {
 			client.executeMethod(method);
-            return method.getResponseHeader("location").getValue();
+			return method.getResponseHeader("location").getValue();
 		} catch (HttpException e) {
 			e.printStackTrace();
 		} catch (IOException e) {

--
Gitblit v1.8.0