1; 集成私密代理方法配置 引入待测
This commit is contained in:
parent
0c03f69473
commit
e3af04aa1f
|
@ -127,7 +127,7 @@ public class MeituanController {
|
||||||
@ApiOperation("getMtgsig")
|
@ApiOperation("getMtgsig")
|
||||||
@GetMapping("/getMtgsig")
|
@GetMapping("/getMtgsig")
|
||||||
public String mtgsig(String orderId,String regionId,String regionVersion,String dfpid) {
|
public String mtgsig(String orderId,String regionId,String regionVersion,String dfpid) {
|
||||||
return iMeituanService.mtgsigInfo(orderId,regionId,regionVersion,dfpid);
|
return iMeituanService.mtgsigInfo(null,orderId,regionId,regionVersion,dfpid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -113,7 +113,7 @@ public class ProxyProperties {
|
||||||
String code = jsonObject.getString(("code"));
|
String code = jsonObject.getString(("code"));
|
||||||
if ("0".equals(code)) {
|
if ("0".equals(code)) {
|
||||||
int count = jsonObject.getJSONObject("data").getInteger(proxy);
|
int count = jsonObject.getJSONObject("data").getInteger(proxy);
|
||||||
if (count > 600) {
|
if (count > 400) {
|
||||||
System.out.println("剩余:"+count);
|
System.out.println("剩余:"+count);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,7 @@ import org.springframework.data.redis.core.StringRedisTemplate;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
|
@ -106,7 +107,7 @@ public class MeituanServiceImpl implements IMeituanService {
|
||||||
if(list1.size() == 0){
|
if(list1.size() == 0){
|
||||||
return "授权失败,代理账号不存在!";
|
return "授权失败,代理账号不存在!";
|
||||||
}
|
}
|
||||||
String getUrl = proxyProperties.getUrl();
|
String getUrl = null;
|
||||||
Date date = new Date();
|
Date date = new Date();
|
||||||
if (list.size() == 0) {
|
if (list.size() == 0) {
|
||||||
storeInfo.setBindId(list1.get(0).getId());
|
storeInfo.setBindId(list1.get(0).getId());
|
||||||
|
@ -285,7 +286,7 @@ public class MeituanServiceImpl implements IMeituanService {
|
||||||
*/
|
*/
|
||||||
public boolean yesterdayCountOne(BusStoreInfo storeInfo){
|
public boolean yesterdayCountOne(BusStoreInfo storeInfo){
|
||||||
|
|
||||||
CloseableHttpClient httpClient = proxyHttpClient(proxyProperties.getUrl());
|
CloseableHttpClient httpClient = proxyHttpClient();
|
||||||
String wmPoiId = valueFromCookie("wmPoiId", storeInfo.getStoreCookie());
|
String wmPoiId = valueFromCookie("wmPoiId", storeInfo.getStoreCookie());
|
||||||
String url = "https://waimaieapp.meituan.com/gw/bizdata/single/business/overview";
|
String url = "https://waimaieapp.meituan.com/gw/bizdata/single/business/overview";
|
||||||
Map<String, Object> params = new HashMap<>();
|
Map<String, Object> params = new HashMap<>();
|
||||||
|
@ -359,7 +360,7 @@ public class MeituanServiceImpl implements IMeituanService {
|
||||||
public R orderInfo(String wmPoiId, String date, String cookie) { //根据date,查询前一天的key,如果有,则删除
|
public R orderInfo(String wmPoiId, String date, String cookie) { //根据date,查询前一天的key,如果有,则删除
|
||||||
|
|
||||||
int pageNum = 1;
|
int pageNum = 1;
|
||||||
String getUrl = proxyProperties.getUrl();
|
String getUrl = null;
|
||||||
JSONObject jsonObject = merchantOrders(getUrl,pageNum, date, cookie);
|
JSONObject jsonObject = merchantOrders(getUrl,pageNum, date, cookie);
|
||||||
String code = jsonObject.getString("code");
|
String code = jsonObject.getString("code");
|
||||||
if ("0".equals(code)) {
|
if ("0".equals(code)) {
|
||||||
|
@ -507,7 +508,7 @@ public class MeituanServiceImpl implements IMeituanService {
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getOrderCountByType(String getUrl, String wmOrderViewId,String cookie){
|
private String getOrderCountByType(String getUrl, String wmOrderViewId,String cookie){
|
||||||
CloseableHttpClient httpClient = proxyHttpClient(getUrl);
|
CloseableHttpClient httpClient = proxyHttpClient();
|
||||||
String url = "https://e.waimai.meituan.com/gw/phf/v2/order/receive/processed/r/orderAsyncInfos/v3";
|
String url = "https://e.waimai.meituan.com/gw/phf/v2/order/receive/processed/r/orderAsyncInfos/v3";
|
||||||
Map<String, Object> params = new HashMap<>();
|
Map<String, Object> params = new HashMap<>();
|
||||||
params.put("region_id", valueFromCookie("region_id",cookie));
|
params.put("region_id", valueFromCookie("region_id",cookie));
|
||||||
|
@ -567,7 +568,7 @@ public class MeituanServiceImpl implements IMeituanService {
|
||||||
httpPost.setHeader("Host","waimaieapp.meituan.com");
|
httpPost.setHeader("Host","waimaieapp.meituan.com");
|
||||||
httpPost.setHeader("User-Agent","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36");
|
httpPost.setHeader("User-Agent","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36");
|
||||||
|
|
||||||
CloseableHttpClient client = proxyHttpClient(getUrl);
|
CloseableHttpClient client = proxyHttpClient();
|
||||||
// CloseableHttpClient client = HttpClientBuilder.create().build();
|
// CloseableHttpClient client = HttpClientBuilder.create().build();
|
||||||
HttpEntity responseEntity;
|
HttpEntity responseEntity;
|
||||||
String resp = null;
|
String resp = null;
|
||||||
|
@ -596,7 +597,7 @@ public class MeituanServiceImpl implements IMeituanService {
|
||||||
HttpGet request = new HttpGet(url);
|
HttpGet request = new HttpGet(url);
|
||||||
request.setHeader("Cookie",cookie);
|
request.setHeader("Cookie",cookie);
|
||||||
request.setHeader("User-Agent","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36");
|
request.setHeader("User-Agent","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36");
|
||||||
CloseableHttpClient client = proxyHttpClient(getUrl);
|
CloseableHttpClient client = proxyHttpClient();
|
||||||
String result = null;
|
String result = null;
|
||||||
try {
|
try {
|
||||||
result = EntityUtils.toString(client.execute(request).getEntity());
|
result = EntityUtils.toString(client.execute(request).getEntity());
|
||||||
|
@ -630,7 +631,7 @@ public class MeituanServiceImpl implements IMeituanService {
|
||||||
HttpGet request = new HttpGet(url);
|
HttpGet request = new HttpGet(url);
|
||||||
request.setHeader("Cookie",cookie);
|
request.setHeader("Cookie",cookie);
|
||||||
request.setHeader("User-Agent","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36");
|
request.setHeader("User-Agent","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36");
|
||||||
CloseableHttpClient client = proxyHttpClient(getUrl);
|
CloseableHttpClient client = proxyHttpClient();
|
||||||
String result = null;
|
String result = null;
|
||||||
try {
|
try {
|
||||||
result = EntityUtils.toString(client.execute(request).getEntity());
|
result = EntityUtils.toString(client.execute(request).getEntity());
|
||||||
|
@ -687,7 +688,7 @@ public class MeituanServiceImpl implements IMeituanService {
|
||||||
httpPost.setEntity(entity);
|
httpPost.setEntity(entity);
|
||||||
httpPost.setHeader("Cookie", cookie);
|
httpPost.setHeader("Cookie", cookie);
|
||||||
|
|
||||||
CloseableHttpClient client = proxyHttpClient(getUrl);
|
CloseableHttpClient client = proxyHttpClient();
|
||||||
|
|
||||||
String code = null;
|
String code = null;
|
||||||
JSONObject jsonObject = new JSONObject();
|
JSONObject jsonObject = new JSONObject();
|
||||||
|
@ -747,42 +748,81 @@ public class MeituanServiceImpl implements IMeituanService {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public String mtgsigInfo(String getUrl, String orderId, String regionId, String regionVersion,String dfpid) {
|
public String mtgsigInfo(String getUrl, String orderId, String regionId, String regionVersion,String dfpid) {
|
||||||
CloseableHttpClient httpClient = proxyHttpClient(getUrl);
|
CloseableHttpClient httpClient = proxyHttpClient();
|
||||||
String url = "http://43.140.224.18:12000/get_mtgsig";
|
String url = "http://43.140.224.18:12000/get_mtgsig";
|
||||||
HttpPost httpPost = new HttpPost(url);
|
HttpPost httpPost = new HttpPost(url);
|
||||||
httpPost.setHeader("Content-Type", "application/x-www-form-urlencoded");
|
httpPost.setHeader("Content-Type", "application/json");
|
||||||
|
|
||||||
Map<String, Object> subUrlParams = new LinkedHashMap<>();
|
Map<String, Object> subUrlParams = new LinkedHashMap<>();
|
||||||
subUrlParams.put("url", "https://e.waimai.meituan.com/v2/order/history/r/search/ajax?");
|
// subUrlParams.put("url", "https://e.waimai.meituan.com/v2/order/history/r/search/ajax?");
|
||||||
// subUrlParams.put("searchItem", orderId);
|
// subUrlParams.put("searchItem", orderId);
|
||||||
// subUrlParams.put("region_id", regionId);
|
// subUrlParams.put("region_id", regionId);
|
||||||
// subUrlParams.put("region_version", regionVersion);
|
// subUrlParams.put("region_version", regionVersion);
|
||||||
// subUrlParams.put("yodaReady", "h5");
|
// subUrlParams.put("yodaReady", "h5");
|
||||||
// subUrlParams.put("csecplatform", 4);
|
// subUrlParams.put("csecplatform", 4);
|
||||||
// subUrlParams.put("csecversion", "2.4.0");
|
// subUrlParams.put("csecversion", "2.4.0");
|
||||||
|
JSONObject jsonObject = new JSONObject();
|
||||||
|
jsonObject.put("url","https://e.waimai.meituan.com/v2/order/history/r/search/ajax?searchItem="+orderId+"®ion_id="+regionId+"®ion_version="+regionVersion+"&yodaReady=h5&csecplatform=4&csecversion=2.4.0");
|
||||||
|
jsonObject.put("data","");
|
||||||
|
jsonObject.put("dfpid",dfpid);
|
||||||
|
jsonObject.put("method","post");
|
||||||
|
StringEntity entity = new StringEntity(JSONObject.toJSONString(jsonObject), "utf-8");
|
||||||
|
|
||||||
subUrlParams.put("data", "");
|
// subUrlParams.put("data", "");
|
||||||
subUrlParams.put("dfpid", dfpid.split("-")[0]);
|
// subUrlParams.put("dfpid", dfpid.split("-")[0]);
|
||||||
subUrlParams.put("method", "post");
|
// subUrlParams.put("method", "post");
|
||||||
|
//
|
||||||
String urlParam = "";
|
// String urlParam = "";
|
||||||
for (Map.Entry<String, Object> stringObjectEntry : subUrlParams.entrySet()) {
|
// for (Map.Entry<String, Object> stringObjectEntry : subUrlParams.entrySet()) {
|
||||||
urlParam = urlParam + stringObjectEntry.getKey() + "=" + stringObjectEntry.getValue() + "&";
|
// urlParam = urlParam + stringObjectEntry.getKey() + "=" + stringObjectEntry.getValue() + "&";
|
||||||
}
|
// }
|
||||||
String result = null;
|
String result = null;
|
||||||
try {
|
try {
|
||||||
StringEntity params = new StringEntity(urlParam.substring(0, urlParam.length() - 1));
|
// StringEntity params = new StringEntity(urlParam.substring(0, urlParam.length() - 1));
|
||||||
httpPost.setEntity(params);
|
httpPost.setEntity(entity);
|
||||||
CloseableHttpResponse response = httpClient.execute(httpPost);
|
CloseableHttpResponse response = httpClient.execute(httpPost);
|
||||||
result = EntityUtils.toString(response.getEntity());
|
result = EntityUtils.toString(response.getEntity());
|
||||||
|
result = URLEncoder.encode(result,"utf-8")
|
||||||
|
.replace("+", "%20")
|
||||||
|
.replace("%21", "!")
|
||||||
|
.replace("%27", "'")
|
||||||
|
.replace("%28", "(")
|
||||||
|
.replace("%29", ")")
|
||||||
|
.replace("%7E", "~");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
}finally {
|
||||||
|
try {
|
||||||
|
httpClient.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return URLEncoder.encode(result);
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// public static void main(String[] args) throws Exception {
|
||||||
|
// String s = "{\n" +
|
||||||
|
// "\"a1\": \"1.1\",\n" +
|
||||||
|
// "\"a2\": 1722262786240,\n" +
|
||||||
|
// "\"a3\": \"1719555287467YYKUWIAfd79fef3d01d5e9aadc18ccd4d0c95077155\",\n" +
|
||||||
|
// "\"a5\": \"Hb6DmbOppfh+9/IyVMq4\",\n" +
|
||||||
|
// "\"a6\": \"hs1.4aOG4x69iuIGtADfqn9IKcXWfqxcu6RKBEt0ULtKkr0Pxmrai6YXTRjzK6Sg7d16jqhHlzuHMnrjVQt4PthJFNw==\",\n" +
|
||||||
|
// "\"x0\": 4,\n" +
|
||||||
|
// "\"d1\": \"9cff2c0335b0bb892a1bd01fa94f978f\"\n" +
|
||||||
|
// "}";
|
||||||
|
// String ss = URLEncoder.encode(s,"utf-8")
|
||||||
|
// .replace("+", "%20")
|
||||||
|
// .replace("%21", "!")
|
||||||
|
// .replace("%27", "'")
|
||||||
|
// .replace("%28", "(")
|
||||||
|
// .replace("%29", ")")
|
||||||
|
// .replace("%7E", "~");
|
||||||
|
// System.out.println(ss);
|
||||||
|
// }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void getReturnInfo(Long id) {
|
public void getReturnInfo(Long id) {
|
||||||
getComments(null);
|
getComments(null);
|
||||||
|
@ -850,7 +890,7 @@ public class MeituanServiceImpl implements IMeituanService {
|
||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Boolean getScoreOne(BusStoreInfo store) {
|
public Boolean getScoreOne(BusStoreInfo store) {
|
||||||
CloseableHttpClient httpClient = proxyHttpClient(proxyProperties.getUrl());
|
CloseableHttpClient httpClient = proxyHttpClient();
|
||||||
String wmPoiId = valueFromCookie("wmPoiId", store.getStoreCookie());
|
String wmPoiId = valueFromCookie("wmPoiId", store.getStoreCookie());
|
||||||
String url = "https://waimaieapp.meituan.com/gw/customer/comment/scores";
|
String url = "https://waimaieapp.meituan.com/gw/customer/comment/scores";
|
||||||
Map<String, Object> params = new HashMap<>();
|
Map<String, Object> params = new HashMap<>();
|
||||||
|
@ -930,7 +970,7 @@ public class MeituanServiceImpl implements IMeituanService {
|
||||||
request.setHeader("Cookie",store.getStoreCookie());
|
request.setHeader("Cookie",store.getStoreCookie());
|
||||||
String result = null;
|
String result = null;
|
||||||
try {
|
try {
|
||||||
CloseableHttpClient httpClient = proxyHttpClient(proxyProperties.getUrl());
|
CloseableHttpClient httpClient = proxyHttpClient();
|
||||||
result = EntityUtils.toString(httpClient.execute(request).getEntity());
|
result = EntityUtils.toString(httpClient.execute(request).getEntity());
|
||||||
if (StringUtils.isEmpty(result)) {
|
if (StringUtils.isEmpty(result)) {
|
||||||
System.out.println(result);
|
System.out.println(result);
|
||||||
|
@ -982,37 +1022,38 @@ public class MeituanServiceImpl implements IMeituanService {
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
private CloseableHttpClient proxyHttpClient(String ipPort) {
|
private CloseableHttpClient proxyHttpClient() {
|
||||||
// String proxyHost = proxyProperties.getProxyAddr();
|
// private CloseableHttpClient proxyHttpClient(String ipPort) {
|
||||||
// int proxyPort = proxyProperties.getProxyPort();
|
String proxyHost = proxyProperties.getProxyAddr();
|
||||||
// String username = proxyProperties.getAccount();
|
int proxyPort = proxyProperties.getProxyPort();
|
||||||
// String password = proxyProperties.getPwd();
|
String username = proxyProperties.getAccount();
|
||||||
// HttpHost proxy = new HttpHost(proxyHost, proxyPort);
|
String password = proxyProperties.getPwd();
|
||||||
// CredentialsProvider credsProvider = new BasicCredentialsProvider();
|
HttpHost proxy = new HttpHost(proxyHost, proxyPort);
|
||||||
// credsProvider.setCredentials(new AuthScope(proxyHost, proxyPort),
|
CredentialsProvider credsProvider = new BasicCredentialsProvider();
|
||||||
// new UsernamePasswordCredentials(username, password));
|
credsProvider.setCredentials(new AuthScope(proxyHost, proxyPort),
|
||||||
// RequestConfig config = RequestConfig.custom().setProxy(proxy).build();
|
new UsernamePasswordCredentials(username, password));
|
||||||
// CloseableHttpClient httpClient = HttpClients
|
RequestConfig config = RequestConfig.custom().setProxy(proxy).build();
|
||||||
// .custom()
|
CloseableHttpClient httpClient = HttpClients
|
||||||
// .setDefaultRequestConfig(config)
|
.custom()
|
||||||
// .setDefaultCredentialsProvider(credsProvider)
|
.setDefaultRequestConfig(config)
|
||||||
// .build();
|
.setDefaultCredentialsProvider(credsProvider)
|
||||||
//// CloseableHttpClient httpClient = HttpClients.custom().setDefaultRequestConfig(config).build();
|
.build();
|
||||||
// return httpClient;
|
// CloseableHttpClient httpClient = HttpClients.custom().setDefaultRequestConfig(config).build();
|
||||||
|
return httpClient;
|
||||||
|
|
||||||
// String ipPort = proxyProperties.getUrl();
|
// String ipPort = proxyProperties.getUrl();
|
||||||
// JDK 8u111版本后,目标页面为HTTPS协议,启用proxy用户密码鉴权
|
// JDK 8u111版本后,目标页面为HTTPS协议,启用proxy用户密码鉴权
|
||||||
System.setProperty("jdk.http.auth.tunneling.disabledSchemes", "");
|
// System.setProperty("jdk.http.auth.tunneling.disabledSchemes", "");
|
||||||
|
//
|
||||||
String ip = ipPort.split(":")[0];
|
// String ip = ipPort.split(":")[0];
|
||||||
int port = Integer.valueOf(ipPort.split(":")[1]);
|
// int port = Integer.valueOf(ipPort.split(":")[1]);
|
||||||
HttpHost proxy = new HttpHost(ip, port);
|
// HttpHost proxy = new HttpHost(ip, port);
|
||||||
CredentialsProvider credsProvider = new BasicCredentialsProvider();
|
// CredentialsProvider credsProvider = new BasicCredentialsProvider();
|
||||||
credsProvider.setCredentials(new AuthScope(ip, port),
|
// credsProvider.setCredentials(new AuthScope(ip, port),
|
||||||
new UsernamePasswordCredentials(proxyProperties.getAccountSM(), proxyProperties.getPwdSM()));
|
// new UsernamePasswordCredentials(proxyProperties.getAccountSM(), proxyProperties.getPwdSM()));
|
||||||
RequestConfig config = RequestConfig.custom().setProxy(proxy).build();
|
// RequestConfig config = RequestConfig.custom().setProxy(proxy).build();
|
||||||
CloseableHttpClient httpclient = HttpClients.custom().setDefaultCredentialsProvider(credsProvider).setDefaultRequestConfig(config).build();
|
// CloseableHttpClient httpclient = HttpClients.custom().setDefaultCredentialsProvider(credsProvider).setDefaultRequestConfig(config).build();
|
||||||
return httpclient;
|
// return httpclient;
|
||||||
// try {
|
// try {
|
||||||
// URL url = new URL(pageUrl);
|
// URL url = new URL(pageUrl);
|
||||||
// HttpHost target = new HttpHost(url.getHost(), url.getDefaultPort(), url.getProtocol());
|
// HttpHost target = new HttpHost(url.getHost(), url.getDefaultPort(), url.getProtocol());
|
||||||
|
|
Loading…
Reference in New Issue