|
@@ -20,7 +20,6 @@ import org.apache.http.client.methods.HttpGet;
|
|
|
import org.apache.http.client.methods.HttpPost;
|
|
|
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
|
|
|
import org.apache.http.conn.ssl.TrustStrategy;
|
|
|
-import org.apache.http.cookie.Cookie;
|
|
|
import org.apache.http.entity.StringEntity;
|
|
|
import org.apache.http.impl.client.BasicCookieStore;
|
|
|
import org.apache.http.impl.client.CloseableHttpClient;
|
|
@@ -75,11 +74,6 @@ public class HttpUtils2 {
|
|
|
HttpPost httppost = new HttpPost(url);
|
|
|
httppost.setHeader("User-Agent", USER_AGENT);
|
|
|
|
|
|
- List<Cookie> list = cookieStore.getCookies();
|
|
|
- for (Cookie ck : list) {
|
|
|
- System.out.println(ck.getName() + "=" + ck.getValue() + "," + ck.getDomain());
|
|
|
- }
|
|
|
- System.out.println("-------------------------------------");
|
|
|
for (String key : headers.keySet()) {
|
|
|
httppost.setHeader(key, headers.get(key));
|
|
|
}
|
|
@@ -93,9 +87,6 @@ public class HttpUtils2 {
|
|
|
UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(paramList);
|
|
|
// 第一步:通过setEntity 将我们的entity对象传递过去
|
|
|
httppost.setEntity(formEntity);
|
|
|
-
|
|
|
- //httppost.setHeader("Content-Type", "application/json");
|
|
|
-// httppost.setEntity(new StringEntity(new Gson().toJson(param), Charset.forName("UTF-8")));
|
|
|
HttpEntity respentity;
|
|
|
|
|
|
HttpResponse response = httpClient.execute(httppost);
|
|
@@ -116,23 +107,15 @@ public class HttpUtils2 {
|
|
|
}
|
|
|
|
|
|
public static String httpPostRequest(String url, Map<String, Object> param, Map<String, String> headers) {
|
|
|
-// HttpClient httpclient = HttpClientBuilder.create().setRedirectStrategy(new LaxRedirectStrategy()).build();
|
|
|
HttpClient httpClient = createSSLClientDefault();
|
|
|
String strReturn = "";
|
|
|
try {
|
|
|
HttpPost httppost = new HttpPost(url);
|
|
|
httppost.setHeader("User-Agent", USER_AGENT);
|
|
|
httppost.addHeader("Content-Type", "application/json");
|
|
|
- List<Cookie> list = cookieStore.getCookies();
|
|
|
- System.out.println("###################################################");
|
|
|
- for (Cookie ck : list) {
|
|
|
- System.out.println(ck.getName() + "=" + ck.getValue() + "," + ck.getDomain());
|
|
|
- }
|
|
|
- System.out.println("###################################################");
|
|
|
for (String key : headers.keySet()) {
|
|
|
httppost.setHeader(key, headers.get(key));
|
|
|
}
|
|
|
- //httppost.setHeader("Content-Type", "application/json");
|
|
|
httppost.setEntity(new StringEntity(new Gson().toJson(param), Charset.forName("UTF-8")));
|
|
|
HttpEntity respentity;
|
|
|
|
|
@@ -155,17 +138,12 @@ public class HttpUtils2 {
|
|
|
|
|
|
|
|
|
public static String httpPostRequestTest(String url, String body, Map<String, String> headers) {
|
|
|
-// HttpClient httpclient = HttpClientBuilder.create().setRedirectStrategy(new LaxRedirectStrategy()).build();
|
|
|
HttpClient httpClient = createSSLClientDefault();
|
|
|
String strReturn = "";
|
|
|
try {
|
|
|
HttpPost httppost = new HttpPost(url);
|
|
|
httppost.setHeader("User-Agent", USER_AGENT);
|
|
|
httppost.addHeader("Content-Type", "application/json");
|
|
|
- List<Cookie> list = cookieStore.getCookies();
|
|
|
- for (Cookie ck : list) {
|
|
|
- System.out.println(ck.getName() + "=" + ck.getValue() + "," + ck.getDomain());
|
|
|
- }
|
|
|
for (String key : headers.keySet()) {
|
|
|
httppost.setHeader(key, headers.get(key));
|
|
|
}
|
|
@@ -205,7 +183,6 @@ public class HttpUtils2 {
|
|
|
httppost.setEntity(new StringEntity(body, Charset.forName("UTF-8")));
|
|
|
}
|
|
|
HttpEntity respentity;
|
|
|
- System.err.println(httppost);
|
|
|
HttpResponse response = httpClient.execute(httppost);
|
|
|
int statusCode = response.getStatusLine().getStatusCode();
|
|
|
if (statusCode == HttpStatus.SC_OK) {
|
|
@@ -229,10 +206,6 @@ public class HttpUtils2 {
|
|
|
HttpPost httppost = new HttpPost(url);
|
|
|
httppost.setHeader("User-Agent", USER_AGENT);
|
|
|
httppost.addHeader("Content-Type", "application/json");
|
|
|
- List<Cookie> list = cookieStore.getCookies();
|
|
|
- for (Cookie ck : list) {
|
|
|
- System.out.println(ck.getName() + "=" + ck.getValue() + "," + ck.getDomain());
|
|
|
- }
|
|
|
for (String key : headers.keySet()) {
|
|
|
httppost.setHeader(key, headers.get(key));
|
|
|
}
|
|
@@ -260,19 +233,10 @@ public class HttpUtils2 {
|
|
|
HttpClient httpClient = createSSLClientDefault();
|
|
|
HttpResponse response = null;
|
|
|
HttpGet httpGet = new HttpGet(url);
|
|
|
-// httpPost.setHeader("Content-Type", "application/json");
|
|
|
String result = null;
|
|
|
try {
|
|
|
httpGet.setHeader("User-Agent", USER_AGENT);
|
|
|
- List<Cookie> list2 = cookieStore.getCookies();
|
|
|
-// for (Cookie ck : list2) {
|
|
|
-// System.out.println(ck.getName() + "=" + ck.getValue() + "," + ck.getDomain());
|
|
|
-// }
|
|
|
response = httpClient.execute(httpGet);
|
|
|
- List<Cookie> list = cookieStore.getCookies();
|
|
|
-// for (Cookie ck : list) {
|
|
|
-// System.out.println(ck.getName() + "=" + ck.getValue() + "," + ck.getDomain());
|
|
|
-// }
|
|
|
int statusCode = response.getStatusLine().getStatusCode();
|
|
|
if (statusCode == HttpStatus.SC_MOVED_PERMANENTLY || statusCode == HttpStatus.SC_MOVED_TEMPORARILY) {
|
|
|
String newUrl = response.getFirstHeader("Location").getValue();
|
|
@@ -294,7 +258,6 @@ public class HttpUtils2 {
|
|
|
}
|
|
|
|
|
|
public static String httpRequest(String url, String strParams) throws Exception {
|
|
|
-// HttpClient httpclient = HttpClientBuilder.create().build();
|
|
|
HttpClient httpClient = createSSLClientDefault();
|
|
|
String strReturn = "";
|
|
|
try {
|
|
@@ -316,7 +279,6 @@ public class HttpUtils2 {
|
|
|
}
|
|
|
|
|
|
public static String httpRequest(String url, CookieStore cookies, Map<String, String> parameterMap) throws Exception {
|
|
|
-// HttpClient httpclient = getHttpclient();
|
|
|
HttpClient httpClient = createSSLClientDefault();
|
|
|
String strReturn = "";
|
|
|
try {
|
|
@@ -358,13 +320,6 @@ public class HttpUtils2 {
|
|
|
HttpClient httpClient = createSSLClientDefault();
|
|
|
HttpResponse response = null;
|
|
|
HttpPost httpPost = new HttpPost(url);
|
|
|
- List<Cookie> list = cookieStore.getCookies();
|
|
|
-// cookieStore.clear();
|
|
|
-// for (Cookie ck : list) {
|
|
|
-//
|
|
|
-// System.out.println(ck.getName() + "=" + ck.getValue() + "," + ck.getDomain());
|
|
|
-// }
|
|
|
-// System.out.println("-------------------------------------");
|
|
|
httpPost.setHeader("Content-Type", "application/json");
|
|
|
String result = null;
|
|
|
|
|
@@ -379,10 +334,6 @@ public class HttpUtils2 {
|
|
|
while ((line = reader.readLine()) != null) {
|
|
|
builder.append(line);
|
|
|
}
|
|
|
-// for (Cookie ck : list) {
|
|
|
-//
|
|
|
-// System.out.println(ck.getName() + "=" + ck.getValue() + "," + ck.getDomain());
|
|
|
-// }
|
|
|
result = builder.toString();
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
@@ -417,44 +368,30 @@ public class HttpUtils2 {
|
|
|
|
|
|
TTFParser ttfParser = new TTFParser();
|
|
|
TrueTypeFont ttf = ttfParser.parse(urlconn.getInputStream());
|
|
|
-// System.out.println(new Gson().toJson(ttf.getGlyph().getGlyphs()));
|
|
|
GlyphData[] datas = ttf.getGlyph().getGlyphs();
|
|
|
CmapSubtable[] tables = ttf.getCmap().getCmaps();
|
|
|
- Gson gson = new Gson();
|
|
|
-// System.out.println(gson.toJson(tables));
|
|
|
CmapSubtable table = tables[0];
|
|
|
- Map<String, Integer> numberMap = new HashMap<String, Integer>();
|
|
|
- Map<String, String> fontMap = new HashMap<String, String>();
|
|
|
+ Map<String, String> fontMap = new HashMap<>();
|
|
|
for (int i = 0; i <= 13; i++) {
|
|
|
GlyphData data = datas[i];
|
|
|
if (data != null) {
|
|
|
-// System.out.println("getBoundingBox" + data.getBoundingBox());
|
|
|
float fx = data.getBoundingBox().getLowerLeftX();
|
|
|
float fy = data.getBoundingBox().getLowerLeftY();
|
|
|
float rx = data.getBoundingBox().getUpperRightX();
|
|
|
float ry = data.getBoundingBox().getUpperRightY();
|
|
|
Integer num = getKuaishouNumber(String.valueOf(rx - fx) + "#" + String.valueOf(ry - fy));
|
|
|
-// if (num != null) {
|
|
|
-// System.out.println(num);
|
|
|
-// }
|
|
|
fontMap.put(String.valueOf((char) table.getCharCodes(i).get(0).intValue()), String.valueOf(num));
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
-// System.out.println(new Gson().toJson(fontMap));
|
|
|
fontsMap.put(ttfName, fontMap);
|
|
|
for (GlyphData data : datas) {
|
|
|
if (data != null) {
|
|
|
-// System.out.println("getBoundingBox" + data.getBoundingBox());
|
|
|
float fx = data.getBoundingBox().getLowerLeftX();
|
|
|
float fy = data.getBoundingBox().getLowerLeftY();
|
|
|
float rx = data.getBoundingBox().getUpperRightX();
|
|
|
float ry = data.getBoundingBox().getUpperRightY();
|
|
|
- Integer num = getKuaishouNumber(String.valueOf(fx) + "#" + String.valueOf(fy) + "#" + String.valueOf(rx) + "#" + String.valueOf(ry));
|
|
|
-// System.out.println(num);
|
|
|
}
|
|
|
}
|
|
|
-// System.out.println(new Gson().toJson(numberMap));
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|