瀏覽代碼

增加快手评论删除定时任务

xuzuoyun 5 年之前
父節點
當前提交
d2c50b31d8

+ 42 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouCommentAutoDelete.java

@@ -0,0 +1,42 @@
+package org.jeecg.modules.ctop.job;
+
+import cn.com.ctop.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import org.jeecg.modules.ctop.entity.BindAccountLogin;
+import org.jeecg.modules.ctop.service.IBindAccountLoginService;
+import org.quartz.Job;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.util.HashMap;
+import java.util.List;
+
+public class KuaishouCommentAutoDelete implements Job {
+    @Autowired
+    private IKuaishouWebInterfaceService kuaishouWebInterfaceService;
+    @Autowired
+    private IBindAccountLoginService bindAccountLoginService;
+
+    @Override
+    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
+        QueryWrapper<BindAccountLogin> queryWrapper = new QueryWrapper<BindAccountLogin>();
+        queryWrapper.eq("login_type", "kuaishou");
+        queryWrapper.eq("status", 1);
+        while (true) {
+            List<BindAccountLogin> list = bindAccountLoginService.list(queryWrapper);
+            if (list != null && list.size() > 0) {
+                for (BindAccountLogin account : list) {
+                    try {
+                        System.out.println("正在删除评论:" + account.getAccountName());
+                        kuaishouWebInterfaceService.adkuaishouWebLogin(account.getAccountName(), account.getPassword());
+                        kuaishouWebInterfaceService.deleteAllComment(new HashMap<>());
+                        Thread.sleep(10000);
+                    } catch (Exception e) {
+                        e.printStackTrace();
+                    }
+                }
+            }
+        }
+    }
+}

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

@@ -74,10 +74,10 @@ public class HttpUtils {
             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 (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));
             }
@@ -122,9 +122,9 @@ public class HttpUtils {
             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 (Cookie ck : list) {
+//                System.out.println(ck.getName() + "=" + ck.getValue() + "," + ck.getDomain());
+//            }
             for (String key : headers.keySet()) {
                 httppost.setHeader(key, headers.get(key));
             }
@@ -190,9 +190,9 @@ public class HttpUtils {
             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 (Cookie ck : list) {
+//                System.out.println(ck.getName() + "=" + ck.getValue() + "," + ck.getDomain());
+//            }
             for (String key : headers.keySet()) {
                 httppost.setHeader(key, headers.get(key));
             }
@@ -226,14 +226,14 @@ public class HttpUtils {
         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());
-            }
+//            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());
-            }
+//            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();
@@ -321,11 +321,11 @@ public class HttpUtils {
         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("-------------------------------------");
+//        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;
 
@@ -340,10 +340,10 @@ public class HttpUtils {
             while ((line = reader.readLine()) != null) {
                 builder.append(line);
             }
-            for (Cookie ck : list) {
-
-                System.out.println(ck.getName() + "=" + ck.getValue() + "," + ck.getDomain());
-            }
+//            for (Cookie ck : list) {
+//
+//                System.out.println(ck.getName() + "=" + ck.getValue() + "," + ck.getDomain());
+//            }
             result = builder.toString();
         } catch (Exception e) {
             e.printStackTrace();
@@ -388,44 +388,44 @@ public class HttpUtils {
 
             TTFParser ttfParser = new TTFParser();
             TrueTypeFont ttf = ttfParser.parse(urlconn.getInputStream());
-            System.out.println(new Gson().toJson(ttf.getGlyph().getGlyphs()));
+//            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));
+//            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>();
             for (int i = 0; i <= 13; i++) {
                 GlyphData data = datas[i];
                 if (data != null) {
-                    System.out.println("getBoundingBox" + data.getBoundingBox());
+//                    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);
-                    }
+//                    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));
+//            System.out.println(new Gson().toJson(fontMap));
             fontsMap.put(ttfName, fontMap);
             for (GlyphData data : datas) {
                 if (data != null) {
-                    System.out.println("getBoundingBox" + data.getBoundingBox());
+//                    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(num);
                 }
             }
-            System.out.println(new Gson().toJson(numberMap));
+//            System.out.println(new Gson().toJson(numberMap));
         } catch (Exception e) {
             e.printStackTrace();
         }

+ 6 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/graphql/service/IKuaishouWebInterfaceService.java

@@ -1,6 +1,12 @@
 package cn.com.ctop.kuaishou.modules.graphql.service;
 
+import java.util.Map;
+
 public interface IKuaishouWebInterfaceService {
     public void getVideoList(String uid);
     public String checkKuaishouUser(String videoUrl);
+
+    public void adkuaishouWebLogin(String phone, String password);
+
+    public void deleteAllComment(Map<String, String> pcursorMap);
 }

+ 28 - 17
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/graphql/service/impl/KuaishouWebInterfaceServiceImpl.java

@@ -188,9 +188,9 @@ public class KuaishouWebInterfaceServiceImpl implements IKuaishouWebInterfaceSer
 
     public void adkuaishouWebLogin(String phone, String password) {
         System.getProperties().setProperty("webdriver.chrome.driver", "D:/chromedriver.exe");
+        ChromeOptions chromeOptions = new ChromeOptions();
+        WebDriver webDriver = new ChromeDriver(chromeOptions);
         try {
-            ChromeOptions chromeOptions = new ChromeOptions();
-            WebDriver webDriver = new ChromeDriver(chromeOptions);
             chromeOptions.addArguments("--headless");
             chromeOptions.addArguments("--no-sandbox");
             chromeOptions.addArguments("--disable-gpu");
@@ -203,13 +203,6 @@ public class KuaishouWebInterfaceServiceImpl implements IKuaishouWebInterfaceSer
             webDriver.get("https://b.e.kuaishou.com");
             //显示等待控制对象
             WebDriverWait webDriverWait = new WebDriverWait(webDriver, 10);
-            //等待输入框可用后输入账号密码
-            for (Cookie cookie : webDriver.manage().getCookies()) {
-                System.out.println(cookie.getName());
-                System.out.println(cookie.getValue());
-            }
-//        String html = webDriver.getPageSource();
-//        System.out.println(html);
             webDriverWait.until(ExpectedConditions.elementToBeClickable(By.cssSelector(".phone input"))).sendKeys(phone);
             webDriverWait.until(ExpectedConditions.elementToBeClickable(By.cssSelector(".password input"))).sendKeys(password);
             //点击登录
@@ -226,9 +219,7 @@ public class KuaishouWebInterfaceServiceImpl implements IKuaishouWebInterfaceSer
             parameterMap.put("pcursorMap", new Gson().toJson(new HashMap<>()));
             parameterMap.put("count", "30");
             while (iterator.hasNext()) {
-
                 String cookieStr = iterator.next().toString();
-                System.out.println(cookieStr);
                 String[] cookieArray = cookieStr.split(";");
                 Map<String, String> cookieMap = new HashMap<String, String>();
                 for (String cookie : cookieArray) {
@@ -240,21 +231,23 @@ public class KuaishouWebInterfaceServiceImpl implements IKuaishouWebInterfaceSer
                 BasicClientCookie clientCookie = new BasicClientCookie(cookieArray[0].split("=")[0],
                         cookieArray[0].split("=")[1]);
                 clientCookie.setDomain("b.e.kuaishou.com");
-//                clientCookie.setDomain(cookieMap.get("domain"));
                 clientCookie.setPath(cookieMap.get("path"));
                 HttpUtils.cookieStore.addCookie(clientCookie);
             }
         } catch (Exception e) {
             e.printStackTrace();
+        } finally {
+            webDriver.close();
+//            HttpUtils.cookieStore.clear();
         }
     }
 
     public void getVideoList(String uid) {
 //        System.getProperties().setProperty("webdriver.chrome.driver", "D:/chromedriver.exe");
         System.getProperties().setProperty("webdriver.chrome.driver", "/usr/bin/chromedriver");
+        ChromeOptions chromeOptions = new ChromeOptions();
+        WebDriver webDriver = new ChromeDriver(chromeOptions);
         try {
-            ChromeOptions chromeOptions = new ChromeOptions();
-            WebDriver webDriver = new ChromeDriver(chromeOptions);
             chromeOptions.addArguments("--headless");
             chromeOptions.addArguments("--no-sandbox");
             chromeOptions.addArguments("--disable-gpu");
@@ -280,16 +273,18 @@ public class KuaishouWebInterfaceServiceImpl implements IKuaishouWebInterfaceSer
             String ttf = "";
             while (m.find()) {
                 ttf = m.group();
-                System.out.println("ttf:" + ttf);
             }
             Map<String, String> map = HttpUtils.fontsMap.get(ttf);
             if (map == null) {
                 HttpUtils.kuaishouTtf(ttf);
             }
             getVedioList(uid, "", ttf, 1);
-            webDriver.close();
+
         } catch (Exception e) {
             e.printStackTrace();
+        } finally {
+//            HttpUtils.cookieStore.clear();
+            webDriver.close();
         }
     }
 
@@ -425,8 +420,24 @@ public class KuaishouWebInterfaceServiceImpl implements IKuaishouWebInterfaceSer
             KuaishouWebInterfaceServiceImpl i = new KuaishouWebInterfaceServiceImpl();
 //            i.adkuaishouWebLogin("17611760019", "a123456");
 //            i.adkuaishouWebLogin("18822179577", "a123456");
-            i.adkuaishouWebLogin("13552374039", "hcst2019");
+//            i.adkuaishouWebLogin("13552374039", "hcst2019");
+//            i.adkuaishouWebLogin("13039662107", "hcst2016");
 //            i.adkuaishouWebLogin("17116890601", "a123456");
+
+//            i.adkuaishouWebLogin("17177387098", "a123456");
+//            i.adkuaishouWebLogin("18166893708", "a123456");
+//            i.adkuaishouWebLogin("15210359106", "a123456");
+//            i.adkuaishouWebLogin("18645838220", "a123456");
+//            i.adkuaishouWebLogin("17611760019", "a123456");
+//            i.adkuaishouWebLogin("13136718701", "a123456");
+//            i.adkuaishouWebLogin("15504583618", "hcghhcr666");
+//            i.adkuaishouWebLogin("17116890621", "a123456");
+//            i.adkuaishouWebLogin("18504583505", "hcghpy555");
+//            i.adkuaishouWebLogin("18811551872", "a123456");
+//            i.adkuaishouWebLogin("13552374039", "hcst2019");
+//            i.adkuaishouWebLogin("17116890601", "a123456");
+            i.adkuaishouWebLogin("18822179577", "a123456");
+
             Thread.sleep(20000);
             i.deleteAllComment(new HashMap<>());
         } catch (Exception e) {

+ 15 - 7
module-toutiao/src/main/java/cn/com/ctop/toutiao/test/Test.java

@@ -126,7 +126,7 @@ public class Test {
                 param3.put("budget",0);
                 param3.put("budget_mode",-1);
                 param2.put("campaign_id","");
-                param2.put("campaign_name", "自动创建测试8");
+                param2.put("campaign_name", "自动创建测试14");
                 param2.put("landing_type",3);
                 param2.put("campaign_type",1);
                 param2.put("budget",param3);
@@ -190,10 +190,11 @@ public class Test {
                 param5.put("delivery_range",1);
                 param5.put("classify",5);
                 param5.put("projectid","");
-                param5.put("download_type",2);
+                param5.put("download_type", 1);
+//                param5.put("download_type",2);
                 param5.put("localGeolocation",new ArrayList<String>());
-                param5.put("external_url", "https://ad.oceanengine.com/tetris/page/1");
-                param5.put("convert_id", 1);
+//                param5.put("external_url", "https://ad.oceanengine.com/tetris/page/1");
+//                param5.put("convert_id", 1637294570512391L);
 //                param5.put("external_url","https://ad.oceanengine.com/tetris/page/"+siteNode.get("data").get(0).get("siteId").asText());
 //                param5.put("convert_id",convNode.get("action_data").get(0).get("id").asLong());
                 param5.put("open_url","");
@@ -210,9 +211,10 @@ public class Test {
                 param5.put("auto_extend_enabled",0);
                 param5.put("budget_mode",0);
                 param5.put("budget",300);
+                param5.put("app_type", 201);
                 param5.put("schedule_type",1);
-                param5.put("start_time","2019-07-02 00:00");
-                param5.put("end_time","2019-07-03 23:59");
+                param5.put("start_time", "2019-09-02 00:00");
+                param5.put("end_time", "2019-09-03 23:59");
                 param5.put("week_schedule",new ArrayList<String>());
                 param5.put("week_time",new ArrayList<ArrayList<Integer>>());
                 param5.put("pricing",9);
@@ -222,9 +224,15 @@ public class Test {
                 param5.put("flow_control_mode",0);
                 param5.put("cpa_bid",1);
                 param5.put("smart_bid_type",0);
+                param5.put("download_url", "https://download.dgstaticresources.net/fusion/android/app-c6-release.apk");
+                param5.put("package", "com.prometheus.c6");
+                param5.put("external_action", 15);
+//                param5.put("convert_id","com.cjijh.yuy");
+//                param5.put("external_actions","com.cjijh.yuy"
+//                );
                 param5.put("adjust_cpa",0);
                 param5.put("app_bid_ratio",new Object());
-                param5.put("name", "自动创建测试8");
+                param5.put("name", "自动创建测试14");
                 param5.put("campaign_id",campaignId);
                 String createResult = HttpUtils.httpPostRequest("https://ad.oceanengine.com/overture/ad/create/",param5,header);
                 System.out.println(createResult);