Ver código fonte

增加接码平台

xuzuoyun 5 anos atrás
pai
commit
f408ba3b01

+ 33 - 3
module-common/src/main/java/cn/com/ctop/common/module/utils/HttpUtils.java

@@ -204,10 +204,15 @@ public class HttpUtils {
             HttpPost httppost = new HttpPost(url);
             httppost.setHeader("User-Agent", USER_AGENT);
             httppost.addHeader("Content-Type", "application/json");
-            for (String key : headers.keySet()) {
-                httppost.setHeader(key, headers.get(key));
+            if (headers != null && headers.size() > 0) {
+                for (String key : headers.keySet()) {
+                    httppost.setHeader(key, headers.get(key));
+                }
             }
-            httppost.setEntity(new StringEntity(new Gson().toJson(param), Charset.forName("UTF-8")));
+            if (param != null && param.size() > 0) {
+                httppost.setEntity(new StringEntity(new Gson().toJson(param), Charset.forName("UTF-8")));
+            }
+
             HttpEntity respentity;
 
             HttpResponse response = httpClient.execute(httppost);
@@ -227,6 +232,31 @@ public class HttpUtils {
         return strReturn;
     }
 
+    public static String httpPostNoParamRequest(String url) {
+        HttpClient httpClient = createSslClientDefault();
+        String strReturn = "";
+        try {
+            HttpPost httppost = new HttpPost(url);
+            httppost.setHeader("User-Agent", USER_AGENT);
+            httppost.addHeader("Content-Type", "application/json");
+            HttpEntity respentity;
+            HttpResponse response = httpClient.execute(httppost);
+            int statusCode = response.getStatusLine().getStatusCode();
+            if (statusCode == HttpStatus.SC_MOVED_PERMANENTLY || statusCode == HttpStatus.SC_MOVED_TEMPORARILY) {
+                String newUrl = response.getFirstHeader("Location").getValue();
+                return httpPostNoParamRequest(newUrl);
+            } else if (statusCode == HttpStatus.SC_OK) {
+                respentity = response.getEntity();
+                strReturn = EntityUtils.toString(respentity);
+                return strReturn;
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            log.error(e.getMessage());
+        }
+        return strReturn;
+    }
+
 
     public static String httpPostRequestTest(String url, String body, Map<String, String> headers) {
         HttpClient httpClient = createSslClientDefault();

+ 90 - 0
module-crawler/src/main/java/cn/com/ctop/crawler/modules/core/util/AppiumUtil.java

@@ -71,6 +71,96 @@ public class AppiumUtil {
         return desiredCapabilities;
     }
 
+    public void loginKuaishou(AndroidDriver androidDriver) {
+        try {
+            for (int i = 0; i < 5; i++) {
+                Thread.sleep(3000L);
+                permissionAllow(androidDriver);
+            }
+            for (int i = 0; i < 3; i++) {
+                Thread.sleep(3000L);
+                closeBtnClick(androidDriver);
+            }
+            WebElement loginBtn = getElementById(androidDriver, "com.smile.gifmaker:id/left_text");
+            if (loginBtn != null && loginBtn.equals("登陆")) {
+                loginBtn.click();
+                WebElement mobileInput = getElementById(androidDriver, "com.smile.gifmaker:id/login_name_et");
+                WebElement nextBtn = getElementById(androidDriver, "com.smile.gifmaker:id/next_view");
+                if (mobileInput != null) {
+                    String token = KuaimiUtil.kuaimiLogin();
+                    String mobile = KuaimiUtil.getMobile(token, "2307");
+                    mobileInput.sendKeys(mobile);
+                    Thread.sleep(2000L);
+                    nextBtn.click();
+                    Thread.sleep(2000L);
+                    WebElement loginTitle = getElementById(androidDriver, "com.smile.gifmaker:id/login_title_tv");
+                    WebElement forgetBtn = getElementById(androidDriver, "com.smile.gifmaker:id/forget_psd_btn");
+                    if (loginTitle != null && loginTitle.equals("输入密码")) {
+                        forgetBtn.click();
+                        Thread.sleep(2000L);
+                        WebElement sendMsgBtn = getElementById(androidDriver, "com.smile.gifmaker:id/verify_tv");
+                        sendMsgBtn.click();
+                        Thread.sleep(5000L);
+                        int i = 0;
+                        while (i < 20) {
+                            String msg = null;
+                            try {
+                                msg = KuaimiUtil.getMessage(token, "2307", mobile);
+                            } catch (Exception e) {
+                                System.out.println("等待" + mobile + "短信验证码");
+                            }
+                            if (msg != null) {
+                                WebElement captchrInput = getElementById(androidDriver, "com.smile.gifmaker:id/verify_et");
+                                captchrInput.sendKeys(msg);
+                                Thread.sleep(2000);
+                                WebElement confirmBtn = getElementById(androidDriver, "com.smile.gifmaker:id/confirm_btn");
+                                confirmBtn.click();
+                                Thread.sleep(2000);
+                                WebElement newPwdInput = getElementById(androidDriver, "com.smile.gifmaker:id/login_psd_et");
+                                newPwdInput.sendKeys("a123456");
+                                Thread.sleep(2000);
+                                WebElement confirmBtn2 = getElementById(androidDriver, "com.smile.gifmaker:id/confirm_btn");
+                                confirmBtn2.click();
+                                Thread.sleep(3000);
+                                WebElement continueBtn = getElementById(androidDriver, "com.smile.gifmaker:id/positive");
+                                if (continueBtn != null) {
+                                    continueBtn.click();
+                                }
+                                Thread.sleep(3000);
+
+                                break;
+                            }
+                            i++;
+                            Thread.sleep(5000);
+                        }
+                        if (i == 20) {
+                            KuaimiUtil.addBlackList(token, "2307", mobile);
+                        }
+                    }
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+    }
+
+    public void permissionAllow(AndroidDriver androidDriver) {
+        WebElement element = getElementById(androidDriver, "com.android.packageinstaller:id/permission_allow_button");
+        if (element != null) {
+            element.click();
+        }
+    }
+
+    public void closeBtnClick(AndroidDriver androidDriver) {
+        WebElement element = getElementById(androidDriver, "com.smile.gifmaker:id/close_btn");
+        if (element != null) {
+            element.click();
+        }
+    }
+
+
+
     public WebElement getElementById(AndroidDriver androidDriver, String id) {
         WebElement element = null;
         List<WebElement> elements = androidDriver.findElementsById(id);

+ 86 - 0
module-crawler/src/main/java/cn/com/ctop/crawler/modules/core/util/KuaimiUtil.java

@@ -0,0 +1,86 @@
+package cn.com.ctop.crawler.modules.core.util;
+
+import cn.com.ctop.common.module.utils.HttpUtils;
+
+public class KuaimiUtil {
+    public static final String KUAIMI_API_URL = "http://api.kmiyz.com/api/do.php";
+
+    public static String kuaimiLogin() throws Exception {
+        String result = HttpUtils.httpPostNoParamRequest(KUAIMI_API_URL + "?action=loginIn&name=xuzuoyun&password=heaven01");
+        if (result != null && result.startsWith("1")) {
+            System.out.println(result);
+            return result.split("\\|")[1];
+        } else {
+            throw new Exception();
+        }
+    }
+
+    public static String getMobile(String token, String projectId) throws Exception {
+        String url = KUAIMI_API_URL + "?action=getPhone&sid=" + projectId + "&token=" + token;
+        String result = HttpUtils.httpPostNoParamRequest(url);
+        System.out.println(result);
+        if (result != null && result.startsWith("1")) {
+            System.out.println(result);
+            return result.split("\\|")[1];
+        } else {
+            throw new Exception();
+        }
+    }
+
+    public static String getMessage(String token, String projectId, String phone) throws Exception {
+        String url = KUAIMI_API_URL + "?action=getMessage&sid=" + projectId + "&token=" + token + "&phone=" + phone;
+        String result = HttpUtils.httpPostNoParamRequest(url);
+        if (result != null && result.startsWith("1")) {
+            System.out.println(result);
+            return result.split("\\|")[1].substring(6, 12);
+        } else {
+            throw new Exception();
+        }
+    }
+
+    public static String addBlackList(String token, String projectId, String phone) throws Exception {
+        String url = KUAIMI_API_URL + "?action=addBlacklist&sid=" + projectId + "&token=" + token + "&phone=" + phone;
+        String result = HttpUtils.httpPostNoParamRequest(url);
+        if (result != null && result.startsWith("1")) {
+            System.out.println(result);
+            return result.split("\\|")[1];
+        } else {
+            throw new Exception();
+        }
+    }
+
+    public static String cancelRecv(String token, String projectId, String phone) throws Exception {
+        String url = KUAIMI_API_URL + "?action=cancelRecv&sid=" + projectId + "&token=" + token + "&phone=" + phone;
+        String result = HttpUtils.httpPostNoParamRequest(url);
+        if (result != null && result.startsWith("1")) {
+            System.out.println(result);
+            return result.split("\\|")[1];
+        } else {
+            throw new Exception();
+        }
+    }
+
+    public static void main(String[] args) {
+        KuaimiUtil k = new KuaimiUtil();
+        try {
+            String token = k.kuaimiLogin();
+            System.out.println(token);
+            String mobile = k.getMobile(token, "2307");
+            int times = 0;
+            while (times < 100) {
+                Thread.sleep(5000);
+                try {
+                    String msg = k.getMessage(token, "2307", mobile);
+                    System.out.println(msg);
+                    break;
+                } catch (Exception e) {
+                    System.out.println("等待短信");
+                }
+                times++;
+            }
+            System.out.println("完成");
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+}

+ 4 - 0
module-crawler/src/main/java/cn/com/ctop/crawler/modules/jiema/service/IKuaimiService.java

@@ -0,0 +1,4 @@
+package cn.com.ctop.crawler.modules.jiema.service;
+
+public interface IKuaimiService {
+}

+ 86 - 0
module-crawler/src/main/java/cn/com/ctop/crawler/modules/jiema/service/impl/KuaimiServiceImpl.java

@@ -0,0 +1,86 @@
+package cn.com.ctop.crawler.modules.jiema.service.impl;
+
+import cn.com.ctop.common.module.utils.HttpUtils;
+
+public class KuaimiServiceImpl {
+    public static final String KUAIMI_API_URL = "http://api.kmiyz.com/api/do.php";
+
+    public String kuaimiLogin() throws Exception {
+        String result = HttpUtils.httpPostNoParamRequest(KUAIMI_API_URL + "?action=loginIn&name=xuzuoyun&password=heaven01");
+        if (result != null && result.startsWith("1")) {
+            System.out.println(result);
+            return result.split("\\|")[1];
+        } else {
+            throw new Exception();
+        }
+    }
+
+    public String getMobile(String token, String projectId) throws Exception {
+        String url = KUAIMI_API_URL + "?action=getPhone&sid=" + projectId + "&token=" + token;
+        String result = HttpUtils.httpPostNoParamRequest(url);
+        System.out.println(result);
+        if (result != null && result.startsWith("1")) {
+            System.out.println(result);
+            return result.split("\\|")[1];
+        } else {
+            throw new Exception();
+        }
+    }
+
+    public String getMessage(String token, String projectId, String phone) throws Exception {
+        String url = KUAIMI_API_URL + "?action=getMessage&sid=" + projectId + "&token=" + token + "&phone=" + phone;
+        String result = HttpUtils.httpPostNoParamRequest(url);
+        if (result != null && result.startsWith("1")) {
+            System.out.println(result);
+            return result.split("\\|")[1].substring(6, 12);
+        } else {
+            throw new Exception();
+        }
+    }
+
+    public String addBlackList(String token, String projectId, String phone) throws Exception {
+        String url = KUAIMI_API_URL + "?action=addBlacklist&sid=" + projectId + "&token=" + token + "&phone=" + phone;
+        String result = HttpUtils.httpPostNoParamRequest(url);
+        if (result != null && result.startsWith("1")) {
+            System.out.println(result);
+            return result.split("\\|")[1];
+        } else {
+            throw new Exception();
+        }
+    }
+
+    public String cancelRecv(String token, String projectId, String phone) throws Exception {
+        String url = KUAIMI_API_URL + "?action=cancelRecv&sid=" + projectId + "&token=" + token + "&phone=" + phone;
+        String result = HttpUtils.httpPostNoParamRequest(url);
+        if (result != null && result.startsWith("1")) {
+            System.out.println(result);
+            return result.split("\\|")[1];
+        } else {
+            throw new Exception();
+        }
+    }
+
+    public static void main(String[] args) {
+        KuaimiServiceImpl k = new KuaimiServiceImpl();
+        try {
+            String token = k.kuaimiLogin();
+            System.out.println(token);
+            String mobile = k.getMobile(token, "2307");
+            int times = 0;
+            while (times < 100) {
+                Thread.sleep(5000);
+                try {
+                    String msg = k.getMessage(token, "2307", mobile);
+                    System.out.println(msg);
+                    break;
+                } catch (Exception e) {
+                    System.out.println("等待短信");
+                }
+                times++;
+            }
+            System.out.println("完成");
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+}

+ 70 - 0
module-crawler/src/main/java/cn/com/ctop/crawler/modules/jiema/service/impl/WumaServiceImpl.java

@@ -0,0 +1,70 @@
+package cn.com.ctop.crawler.modules.jiema.service.impl;
+
+import cn.com.ctop.common.module.utils.HttpUtils;
+
+public class WumaServiceImpl {
+    public static final String WUMA_API_URL = "http://56ji.cn:7777";
+
+    public String login() throws Exception {
+//        String result = HttpUtils.httpPostNoParamRequest(WUMA_API_URL+"/Login?uName=xuzuoyun&pWord=heaven&isFixed=ojbk&Developer=U4iw3O%2fWTw6%2b17rjP8rmuA%3d%3d");
+        String result = HttpUtils.httpGetRequest(WUMA_API_URL + "/Login?uName=xuzuoyun&pWord=heaven&isFixed=ojbk&Developer=U4iw3O%2fWTw6%2b17rjP8rmuA%3d%3d");
+        return result.split("&")[0];
+    }
+
+    public String getMobile(String token) {
+        String result = HttpUtils.httpGetRequest(WUMA_API_URL + "/getPhone?ItemId=3244&token=" + token);
+        return result;
+    }
+//    public String getMobile(String token,String projectId) throws Exception{
+//        String url = KUAIMI_API_URL+"?action=getPhone&sid="+projectId+"&token="+token;
+//        String result = HttpUtils.httpPostNoParamRequest(url);
+//        System.out.println(result);
+//        if(result != null && result.startsWith("1")){
+//            System.out.println(result);
+//            return result.split("\\|")[1];
+//        }else {
+//            throw new Exception();
+//        }
+//    }
+//    public String getMessage(String token,String projectId,String phone) throws Exception{
+//        String url = KUAIMI_API_URL+"?action=getMessage&sid="+projectId+"&token="+token+"&phone="+phone;
+//        String result = HttpUtils.httpPostNoParamRequest(url);
+//        if(result != null && result.startsWith("1")){
+//            System.out.println(result);
+//            return result.split("\\|")[1].substring(6,12);
+//        }else {
+//            throw new Exception();
+//        }
+//    }
+//    public String addBlackList(String token,String projectId,String phone) throws Exception{
+//        String url = KUAIMI_API_URL+"?action=addBlacklist&sid="+projectId+"&token="+token+"&phone="+phone;
+//        String result = HttpUtils.httpPostNoParamRequest(url);
+//        if(result != null && result.startsWith("1")){
+//            System.out.println(result);
+//            return result.split("\\|")[1];
+//        }else {
+//            throw new Exception();
+//        }
+//    }
+//    public String cancelRecv(String token,String projectId,String phone) throws Exception{
+//        String url = KUAIMI_API_URL+"?action=cancelRecv&sid="+projectId+"&token="+token+"&phone="+phone;
+//        String result = HttpUtils.httpPostNoParamRequest(url);
+//        if(result != null && result.startsWith("1")){
+//            System.out.println(result);
+//            return result.split("\\|")[1];
+//        }else {
+//            throw new Exception();
+//        }
+//    }
+
+    public static void main(String[] args) {
+        WumaServiceImpl k = new WumaServiceImpl();
+        try {
+            String token = k.login();
+            String mobile = k.getMobile(token);
+            System.out.println(mobile);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+}

+ 1 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java

@@ -804,7 +804,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
             var creative = JSONObject.toJavaObject(detailJson, KuaishouReportHourlyCreative.class);
             creative.setAccountId(token.getAccountId());
             creative.setId("" + creative.getAccountId() + creative.getCreativeId() + creative.getStatDate() + creative.getStatHour());
-//            KuaishouReportHourlyCreativeStatistic statistic = setHourlyStatistic(creative, token);
+            KuaishouReportHourlyCreativeStatistic statistic = setHourlyStatistic(creative, token);
 //            hourlyCreativeStatisticService.saveOrUpdate(statistic);
             hourlyCreativeService.saveOrUpdate(creative);
         }