|
@@ -36,17 +36,21 @@ public class KuaishouUtil {
|
|
|
Map<String,String> dynamicParams = httpEntity.getHttpBody().getDynamicParams();
|
|
|
List<String> ignoreKeyList = new ArrayList<String>();
|
|
|
ignoreKeyList.add("sig");
|
|
|
+ ignoreKeyList.add("__NS_sig3");
|
|
|
ignoreKeyList.add("__NStokensig");
|
|
|
String staticQueryString = HttpParamUtil.mapToUrlString(staticParams,null);
|
|
|
Map<String,String> allMap = new HashMap<String,String>();
|
|
|
allMap.putAll(staticParams);
|
|
|
allMap.putAll(dynamicParams);
|
|
|
if (staticParams.get("kpf") != null && "ANDROID_PHONE".equals(staticParams.get("kpf"))) {
|
|
|
+ System.out.println(HttpParamUtil.mapToString(SortUtil.sortMapByKey(allMap), ignoreKeyList));
|
|
|
String sig = SignUtil.getMd5Sign(HttpParamUtil.mapToString(SortUtil.sortMapByKey(allMap), ignoreKeyList), salt);
|
|
|
dynamicParams.put("sig",sig);
|
|
|
allMap.put("sig",sig);
|
|
|
+ System.out.println(sig);
|
|
|
}
|
|
|
- String dynamicQueryString = HttpParamUtil.mapToUrlString(dynamicParams,null);
|
|
|
+
|
|
|
+ String dynamicQueryString = HttpParamUtil.mapToUrlStringNoEncoder(dynamicParams,null);
|
|
|
BasicCookieStore cookieStore = new BasicCookieStore();
|
|
|
for(HttpCookie cookie : httpEntity.getCookies()){
|
|
|
BasicClientCookie clientCookie = new BasicClientCookie(cookie.getName(),cookie.getValue());
|
|
@@ -72,6 +76,7 @@ public class KuaishouUtil {
|
|
|
}
|
|
|
CloseableHttpClient httpClient = HttpClients.custom().setDefaultCookieStore(cookieStore).setDefaultRequestConfig(globalConfig).setConnectionReuseStrategy((response, context) -> false ).setSSLSocketFactory(sslFactory).build();
|
|
|
HttpPost httppost = new HttpPost(httpEntity.getUrl()+httpEntity.getPath()+"?"+staticQueryString);
|
|
|
+ System.out.println(httpEntity.getUrl()+httpEntity.getPath()+"?"+staticQueryString);
|
|
|
HttpHeader header = httpEntity.getHttpHeader();
|
|
|
Map<String,String> headers = header.getHeaders();
|
|
|
if(headers != null){
|
|
@@ -80,10 +85,12 @@ public class KuaishouUtil {
|
|
|
}
|
|
|
}
|
|
|
httppost.setEntity(new StringEntity(dynamicQueryString));
|
|
|
+ System.out.println(dynamicQueryString);
|
|
|
HttpResponse response = httpClient.execute(httppost);
|
|
|
int code = response.getStatusLine().getStatusCode();
|
|
|
org.apache.http.HttpEntity respentity = response.getEntity();
|
|
|
String strReturn = EntityUtils.toString(respentity);
|
|
|
+ System.out.println(strReturn);
|
|
|
long endTime = System.currentTimeMillis();
|
|
|
crawlerLog.setUrl(httpEntity.getUrl());
|
|
|
crawlerLog.setPath(httpEntity.getPath());
|