|
@@ -7,10 +7,7 @@ import org.apache.fontbox.ttf.CmapSubtable;
|
|
import org.apache.fontbox.ttf.GlyphData;
|
|
import org.apache.fontbox.ttf.GlyphData;
|
|
import org.apache.fontbox.ttf.TTFParser;
|
|
import org.apache.fontbox.ttf.TTFParser;
|
|
import org.apache.fontbox.ttf.TrueTypeFont;
|
|
import org.apache.fontbox.ttf.TrueTypeFont;
|
|
-import org.apache.http.HttpEntity;
|
|
|
|
-import org.apache.http.HttpResponse;
|
|
|
|
-import org.apache.http.HttpStatus;
|
|
|
|
-import org.apache.http.NameValuePair;
|
|
|
|
|
|
+import org.apache.http.*;
|
|
import org.apache.http.client.CookieStore;
|
|
import org.apache.http.client.CookieStore;
|
|
import org.apache.http.client.HttpClient;
|
|
import org.apache.http.client.HttpClient;
|
|
import org.apache.http.client.config.CookieSpecs;
|
|
import org.apache.http.client.config.CookieSpecs;
|
|
@@ -29,6 +26,7 @@ import org.apache.http.impl.client.BasicCookieStore;
|
|
import org.apache.http.impl.client.CloseableHttpClient;
|
|
import org.apache.http.impl.client.CloseableHttpClient;
|
|
import org.apache.http.impl.client.HttpClientBuilder;
|
|
import org.apache.http.impl.client.HttpClientBuilder;
|
|
import org.apache.http.impl.client.HttpClients;
|
|
import org.apache.http.impl.client.HttpClients;
|
|
|
|
+import org.apache.http.impl.cookie.BasicClientCookie;
|
|
import org.apache.http.message.BasicNameValuePair;
|
|
import org.apache.http.message.BasicNameValuePair;
|
|
import org.apache.http.ssl.SSLContextBuilder;
|
|
import org.apache.http.ssl.SSLContextBuilder;
|
|
import org.apache.http.util.EntityUtils;
|
|
import org.apache.http.util.EntityUtils;
|
|
@@ -417,6 +415,18 @@ public class HttpUtils {
|
|
return strReturn;
|
|
return strReturn;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public static void main(String[] args){
|
|
|
|
+ String res = HttpUtils.getKuaishouShareUrl("http://yongzhou.s.gifshow.com/i/photo/lwx?userId=1400097524&photoId=5191805968879099278");
|
|
|
|
+ String path = res.split("\\?")[0];
|
|
|
|
+ String photoId = path.substring(path.lastIndexOf("/")+1,path.length());
|
|
|
|
+ path =path.substring(0,path.lastIndexOf("/"));
|
|
|
|
+ String uid = path.substring(path.lastIndexOf("/")+1,path.length());
|
|
|
|
+ System.out.println(uid);
|
|
|
|
+ System.out.println(photoId);
|
|
|
|
+ res = HttpUtils.postKuaishouVideoUrl("https://live.kuaishou.com/m_graphql",uid,photoId);
|
|
|
|
+ System.out.println(res);
|
|
|
|
+ }
|
|
|
|
+
|
|
public static String postKuaishouVideoUrl(String url,String uid,String photoId){
|
|
public static String postKuaishouVideoUrl(String url,String uid,String photoId){
|
|
HttpClient httpClient = createSslClientDefault();
|
|
HttpClient httpClient = createSslClientDefault();
|
|
String strReturn = "";
|
|
String strReturn = "";
|
|
@@ -482,8 +492,10 @@ public class HttpUtils {
|
|
httpGet.setHeader("User-Agent", USER_AGENT);
|
|
httpGet.setHeader("User-Agent", USER_AGENT);
|
|
response = httpClient.execute(httpGet);
|
|
response = httpClient.execute(httpGet);
|
|
int statusCode = response.getStatusLine().getStatusCode();
|
|
int statusCode = response.getStatusLine().getStatusCode();
|
|
|
|
+ System.out.println(statusCode);
|
|
if (statusCode == HttpStatus.SC_MOVED_PERMANENTLY || statusCode == HttpStatus.SC_MOVED_TEMPORARILY) {
|
|
if (statusCode == HttpStatus.SC_MOVED_PERMANENTLY || statusCode == HttpStatus.SC_MOVED_TEMPORARILY) {
|
|
String newUrl = response.getFirstHeader("Location").getValue();
|
|
String newUrl = response.getFirstHeader("Location").getValue();
|
|
|
|
+ System.out.println(newUrl);
|
|
return httpGetRequest(newUrl);
|
|
return httpGetRequest(newUrl);
|
|
} else if (statusCode == HttpStatus.SC_OK) {
|
|
} else if (statusCode == HttpStatus.SC_OK) {
|
|
BufferedReader reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
|
|
BufferedReader reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
|
|
@@ -746,7 +758,7 @@ public class HttpUtils {
|
|
urlStr = url;
|
|
urlStr = url;
|
|
}
|
|
}
|
|
HttpGet httpget = new HttpGet(urlStr);
|
|
HttpGet httpget = new HttpGet(urlStr);
|
|
- httpget.setHeader("User-Agent", USER_AGENT);
|
|
|
|
|
|
+// httpget.setHeader("User-Agent", USER_AGENT);
|
|
if (!Check.isNullMap(headers)) {
|
|
if (!Check.isNullMap(headers)) {
|
|
for (String key : headers.keySet()) {
|
|
for (String key : headers.keySet()) {
|
|
httpget.setHeader(key, headers.get(key));
|
|
httpget.setHeader(key, headers.get(key));
|
|
@@ -755,6 +767,17 @@ public class HttpUtils {
|
|
HttpEntity respEntity;
|
|
HttpEntity respEntity;
|
|
HttpResponse response = httpclient.execute(httpget);
|
|
HttpResponse response = httpclient.execute(httpget);
|
|
respEntity = response.getEntity();
|
|
respEntity = response.getEntity();
|
|
|
|
+ Header[] responseHeaders = response.getHeaders("Set-Cookie");
|
|
|
|
+ if(responseHeaders != null){
|
|
|
|
+
|
|
|
|
+ for(Header header : responseHeaders){
|
|
|
|
+ String[] ckArray = header.getValue().split(";");
|
|
|
|
+ BasicClientCookie ck = new BasicClientCookie(ckArray[0].split("=")[0], ckArray[0].split("=")[1]);
|
|
|
|
+ ck.setPath(ckArray[1].split("=")[1]);
|
|
|
|
+ ck.setDomain(ckArray[2].split("=")[1]);
|
|
|
|
+ HttpUtils.COOKIESTORE.addCookie(ck);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
result = EntityUtils.toString(respEntity);
|
|
result = EntityUtils.toString(respEntity);
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
log.error("http get请求异常");
|
|
log.error("http get请求异常");
|
|
@@ -899,6 +922,7 @@ public class HttpUtils {
|
|
}
|
|
}
|
|
|
|
|
|
public static JSONObject feishuGetRequest(String accessToken, String url, JSONObject params) {
|
|
public static JSONObject feishuGetRequest(String accessToken, String url, JSONObject params) {
|
|
|
|
+ System.out.println(url);
|
|
// 构造请求
|
|
// 构造请求
|
|
HttpEntityEnclosingRequestBase httpEntity = new HttpEntityEnclosingRequestBase() {
|
|
HttpEntityEnclosingRequestBase httpEntity = new HttpEntityEnclosingRequestBase() {
|
|
@Override
|
|
@Override
|