瀏覽代碼

Merge branch 'master' of https://gitee.com/hcst/adsp-boot

syh 5 年之前
父節點
當前提交
aaec9af54b

+ 4 - 7
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ByteDanceAdvertiserPostController.java

@@ -125,13 +125,10 @@ public class ByteDanceAdvertiserPostController {
      * 11:创建广告组信息
      * @param accountId 本平台广告主id
      */
-    @RequestMapping("/advertiser/campaign/create")
-    public Map<String, Object> advertiserCampaignCreate(String accountId, String campaignName, String budgetMode, Integer budget, String landingType) {
-        return campaignTemplateService.campaignCreate(accountId, campaignName, budgetMode, budget, landingType);
-    }
-
-    @Autowired
-    private IByteDanceCampaignTemplateService campaignTemplateService;
+//    @RequestMapping("/advertiser/campaign/create")
+//    public Map<String, Object> advertiserCampaignCreate(String accountId, String campaignName, String budgetMode, Integer budget, String landingType) {
+//        return advertiserDataService.advertiserCampaignCreate(accountId, campaignName, budgetMode, budget, landingType);
+//    }
 
     /**
      * 11:创建广告计划信息

+ 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();
+                    }
+                }
+            }
+        }
+    }
+}

+ 42 - 205
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/CreateInternalServiceImpl.java

@@ -49,29 +49,10 @@ public class CreateInternalServiceImpl implements ICreateInternalService {
             for (Cookie cookie : webDriver.manage().getCookies()) {
                 BasicClientCookie ck = new BasicClientCookie(cookie.getName(), cookie.getValue());
                 ck.setDomain("ad.oceanengine.com");
-
-
-//                if (cookie.getDomain().startsWith(".")){
-//                    ck.setDomain(cookie.getDomain().substring(1));
-//                }else {
-//                    ck.setDomain(cookie.getDomain());
-//                }
-
                 ck.setExpiryDate(cookie.getExpiry());
                 ck.setPath(cookie.getPath());
                 HttpUtils.cookieStore.addCookie(ck);
-                System.out.println(cookie.getName() + "," + cookie.getValue() + "," + cookie.getDomain());
-
-                BasicClientCookie ck2 = new BasicClientCookie(cookie.getName(), cookie.getValue());
-                ck2.setDomain("toutiao.com");
-
-                ck2.setExpiryDate(cookie.getExpiry());
-                ck2.setPath(cookie.getPath());
-                HttpUtils.cookieStore.addCookie(ck2);
-//                ck.setDomain(".sso.toutiao.com");
-//                HttpUtils.cookieStore.addCookie(ck);
             }
-
             String html = webDriver.getPageSource();
             Map<String, String> header = new HashMap<String, String>();
             header.put("Accept", "*/*");
@@ -83,20 +64,12 @@ public class CreateInternalServiceImpl implements ICreateInternalService {
             Map<String, Object> param = new HashMap<String, Object>();
             param.put("mobile", "");
             param.put("code", "");
-//            param.put("account","guoyanling@c-top.com.cn");
-//            param.put("password","Hcstad-567");
             param.put("account", "dcd_ad@bytedance.com");
             param.put("password", "typdDCD@2018");
             param.put("captcha", "hqde");
             param.put("is_30_days_no_login", "true");
             param.put("service", "https://ad.oceanengine.com");
             String res = HttpUtils.httpPostParamRequest("https://sso.toutiao.com/account_login/", param, header);
-//            System.out.println(res);
-//            Scanner scanner = new Scanner(System.in);
-//            String code = scanner.nextLine();
-//            param.put("captcha",code);
-//            res = HttpUtils.httpPostParamRequest("https://sso.toutiao.com/account_login/",param,header);
-//            System.out.println(res);
             ObjectMapper mapper = new ObjectMapper();
             mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
             JsonNode jsonNode = mapper.readTree(res);
@@ -119,8 +92,6 @@ public class CreateInternalServiceImpl implements ICreateInternalService {
                 errorCode = jsonNode.get("error_code").asInt();
             }
             if (errorCode == 0) {
-//                String redirectUrl = jsonNode.get("redirect_url").asText();
-//                webDriver.get(redirectUrl);
                 String csrftoken = "";
                 List<org.apache.http.cookie.Cookie> cookies = HttpUtils.cookieStore.getCookies();
                 for (org.apache.http.cookie.Cookie ck : cookies) {
@@ -129,11 +100,8 @@ public class CreateInternalServiceImpl implements ICreateInternalService {
                 }
 
                 webDriver.get("https://ad.oceanengine.com/pages/promotion.html#/ad");//登录成功 进入推广页面
-
+                Thread.sleep(3000);
                 webDriver.get("https://ad.oceanengine.com/pages/campaign/create.html");//创建广告组页面
-//                HttpUtils.httpGetRequest("https://ad.toutiao.com/pages/promotion.html#/ad");
-//                HttpUtils.httpGetRequest("https://ad.toutiao.com/pages/campaign/create.html");
-
                 Map<String, Object> param2 = new HashMap<String, Object>();
                 Map<String, Object> param3 = new HashMap<String, Object>();
                 String uuid = UUID.randomUUID().toString();
@@ -151,24 +119,10 @@ public class CreateInternalServiceImpl implements ICreateInternalService {
                         csrftoken = cookie.getValue();
                     }
                     BasicClientCookie ck = new BasicClientCookie(cookie.getName(), cookie.getValue());
-//                    if (cookie.getDomain().startsWith(".")){
-//                        ck.setDomain(URLDecoder.decode(cookie.getDomain().substring(1),"utf-8"));
-//                    }else {
-//                        ck.setDomain(URLDecoder.decode(cookie.getDomain(),"utf-8"));
-//                    }
                     ck.setDomain("ad.oceanengine.com");
-
                     ck.setExpiryDate(cookie.getExpiry());
                     ck.setPath(cookie.getPath());
                     HttpUtils.cookieStore.addCookie(ck);
-                    System.out.println(cookie.getName() + "," + cookie.getValue() + "," + cookie.getDomain());
-
-                    BasicClientCookie ck2 = new BasicClientCookie(cookie.getName(), cookie.getValue());
-                    ck2.setDomain("toutiao.com");
-
-                    ck2.setExpiryDate(cookie.getExpiry());
-                    ck2.setPath(cookie.getPath());
-                    HttpUtils.cookieStore.addCookie(ck2);
                 }
                 header.put("Accept", "application/json, text/javascript, */*; q=0.01");
                 header.put("Connection", "keep-alive");
@@ -181,50 +135,50 @@ public class CreateInternalServiceImpl implements ICreateInternalService {
                 res = HttpUtils.httpPostRequest("https://ad.oceanengine.com/overture/campaign/create/", param2, header);// 创建广告组返回信息
                 System.out.println(res);
                 JsonNode node = mapper.readTree(res);
-                //{"status": "fail", "msg": "\u5e7f\u544a\u7ec4\u4e0d\u80fd\u91cd\u590d", "type": "form_error", "name": "campaign_name"}
                 String campaignId = node.get("data").get("campaign_id").asText();  //广告组id
                 String url2 = "https://ad.oceanengine.com/pages/ad/create.html?campaign_id=" + campaignId + "&landing_type=3&temp_id=ADvQb";
                 webDriver.get(url2);
-//                webDriver.get("https://ad.toutiao.com/agent/get_agency/?advertiser_id=1634948959249411");
                 header.put("Referer", url2);
                 for (Cookie cookie : webDriver.manage().getCookies()) {
                     BasicClientCookie ck = new BasicClientCookie(cookie.getName(), cookie.getValue());
                     ck.setDomain("ad.oceanengine.com");
-
                     ck.setExpiryDate(cookie.getExpiry());
                     ck.setPath(cookie.getPath());
                     HttpUtils.cookieStore.addCookie(ck);
-                    System.out.println(cookie.getName() + "," + cookie.getValue() + "," + cookie.getDomain());
-
-                    BasicClientCookie ck2 = new BasicClientCookie(cookie.getName(), cookie.getValue());
-                    ck2.setDomain("toutiao.com");
-
-                    ck2.setExpiryDate(cookie.getExpiry());
-                    ck2.setPath(cookie.getPath());
-                    HttpUtils.cookieStore.addCookie(ck2);
                 }
-                String siteStr = HttpUtils.httpGetRequest("https://ad.oceanengine.com/overture/api/adv_site/get_site_list/?_=" + String.valueOf(new Date().getTime()));
-                String convStr = HttpUtils.httpGetRequest("https://ad.oceanengine.com/overture/api/get_tetris_action/?external_url=&type=external&pricing=9&landing_type=3&_=" + String.valueOf(new Date().getTime()));
-                JsonNode siteNode = mapper.readTree(siteStr);
-                JsonNode convNode = mapper.readTree(convStr);
+//                String siteStr = HttpUtils.httpGetRequest("https://ad.oceanengine.com/overture/api/adv_site/get_site_list/?_="+String.valueOf(new Date().getTime()));
+//                String convStr = HttpUtils.httpGetRequest("https://ad.oceanengine.com/overture/api/get_tetris_action/?external_url=&type=external&pricing=9&landing_type=3&_="+String.valueOf(new Date().getTime()));
+//                JsonNode siteNode = mapper.readTree(siteStr);
+//                JsonNode convNode = mapper.readTree(convStr);
 
                 Map<String, Object> param4 = new HashMap<String, Object>();
                 param4.put("location_type", 4);
                 param4.put("aweme_account_fans", 0);
                 String tokenStr = HttpUtils.httpPostRequest("https://ad.oceanengine.com/api/v1/hl/ad/audience/estimate/", param4, header);
-                System.out.println(siteStr);
-                System.out.println(convStr);
-                System.out.println(tokenStr);
                 JsonNode tokenNode = mapper.readTree(tokenStr);
                 Map<String, Object> param5 = new HashMap<String, Object>();
-                /*param5.put("name", "自动创建测试4");  //广计划名称
+                param5.put("name", requestJson.getString("templateName"));//模板名称
+                Integer deliveryRange = requestJson.getInteger("deliveryRange");
+                param5.put("delivery_range", deliveryRange);  //投放形式
+                if (deliveryRange == 2) {
+                    param5.put("union_video_type", requestJson.getInteger("deliveryForm")); //投放形式 1:激励视频 2:原生
+                }
+                param5.put("classify", requestJson.getString("adCategory")); //广告类别
+                param5.put("projectid", ""); //
+                Integer downloadType = requestJson.getInteger("downloadType");
+                param5.put("download_type", downloadType); //下载方式  1:下载包 2:h5
+                if (downloadType == 1) {
+                    param5.put("download_url", requestJson.getString("downloadUrl"));
+                }
+                if (downloadType == 2) {
+                    param5.put("external_url", requestJson.getString("externalUrl"));  // 落地页链接
+                }
                 param5.put("delivery_range", 1);  // 投放范围
                 param5.put("classify", 5);  //广告类别  5 内广
                 param5.put("projectid", "");
-                param5.put("download_type", 2);  //下载方式    1下载链接 2包含下载链接的落地页
                 param5.put("localGeolocation", new ArrayList<String>());
-                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()); // 转换id
+                param5.put("external_action", 4);
+//                param5.put("external_url", "");
                 param5.put("open_url", ""); //  应用直达链接
                 param5.put("style_type", 0);
                 param5.put("location_type", 4); //受众位置类型
@@ -237,153 +191,36 @@ public class CreateInternalServiceImpl implements ICreateInternalService {
                 param5.put("hotsoon", 40000005); //火山预估数据
                 param5.put("aweme_account_fans", 0); //账号粉丝相似人群
                 param5.put("auto_extend_enabled", 0);// 智能放量????
-                param5.put("budget_mode", 0);  // 广告预算类型  0 日预算  1 总预算
-                param5.put("budget", 300); //广告预算
-                param5.put("schedule_type", 1); //广告投放时间类型   默认1 1:不限  2:按时间???
-                param5.put("start_time", "2019-07-02 00:00"); //广告投放起始时间
-                param5.put("end_time", "2019-07-03 23:59");//广告投放结束时间
+                param5.put("budget_mode", requestJson.getIntValue("budgetPriceMode"));  // 广告预算类型  0 日预算  1 总预算
+                param5.put("budget", requestJson.getIntValue("budgetPrice")); //广告预算
+                int scheduleType = requestJson.getIntValue("dateQuantum");
+                param5.put("schedule_type", scheduleType); //广告投放时间类型   默认1 1:不限  2:按时间???
+                if (scheduleType == 2) {
+                    param5.put("start_time", requestJson.getString("startDate")); //广告投放起始时间
+                    param5.put("end_time", requestJson.getString("endDate"));//广告投放结束时间
+                }
+
                 param5.put("week_schedule", new ArrayList<String>());  //投放时段
                 param5.put("week_time", new ArrayList<ArrayList<Integer>>());//投放时段
-                param5.put("pricing", 9); //计划出价类型  9 按展示付费  7 按点击付费 8 按转化付费
+                int pricing = requestJson.getIntValue("pricing");
+                param5.put("pricing", pricing); //计划出价类型  9 按展示付费  7 按点击付费 8 按转化付费
                 param5.put("cpa_phrase", 2); //出价为OCPC时,计划处于哪个阶段??
                 param5.put("is_union_slot", "");
                 param5.put("hide_if_converted", 1); //过滤已转化用户类型字段,只有转化为目标时可填 优化目标为转化才展示
-                param5.put("flow_control_mode", 0); //投放速度/投放方式使用字段
-                param5.put("cpa_bid", 1);
-                param5.put("smart_bid_type", 0); //自动出价类型,OCPM支持
-                param5.put("adjust_cpa", 0); //是否调整自动出价   允许值: "0", "1"  默认值: 0
-                param5.put("app_bid_ratio", new Object());
-                param5.put("campaign_id", campaignId);*/
-
-
-//                param5.put("name", requestJson.getString("templateName"));  //广计划名称
-               /* param5.put("name", param2.get("campaign_name"));
-                param5.put("delivery_range", requestJson.getInteger("deliveryRange"));  // 投放范围
-                param5.put("classify", requestJson.getInteger("adCategory"));  //广告类别  5 内广
-                param5.put("projectid", "");
-                //     param5.put("target", requestJson.getString("deliveryTarget")); //投放目标
-                param5.put("download_type", requestJson.getInteger("downloadType"));  //下载方式    1下载链接 2包含下载链接的落地页
-                param5.put("localGeolocation", new ArrayList<String>());
-
-                String downloadUrl = "";
-                if (!Check.isNull(requestJson.getString("downloadUrl"))) {
-                    downloadUrl = requestJson.getString("downloadUrl");
+                param5.put("flow_control_mode", requestJson.getIntValue("flowControlMode")); //投放速度/投放方式使用字段
+                if (pricing == 9) {
+                    param5.put("cpa_bid", requestJson.getIntValue("convertPrice"));
                 } else {
-                    downloadUrl = requestJson.getString("externalUrl");
+                    param5.put("bid", requestJson.getIntValue("convertPrice"));
                 }
 
-                //   param5.put("external_url", downloadUrl);  // 落地页链接
-                param5.put("download_url", downloadUrl);  // 下载链接
-                param5.put("package", "com.prometheus.c6");  // 包
-                param5.put("app_type", 201);  // app類型
-                //      param5.put("convert_id", convNode.get("action_data").get(0).get("id").asLong()); // 转换id
-                param5.put("open_url", ""); //  应用直达链接
-                param5.put("style_type", 0);
-                param5.put("location_type", 4); //受众位置类型
-                param5.put("hide_if_exists", 0); // 过滤已安装,当推广目标为安卓应用下载时可填,0表示不过滤,1表示过滤,默认为不过滤
-                param5.put("interest_tag_mode", 0); //兴趣分类
-                param5.put("token", tokenNode.get("data").get("token").asText());
-                param5.put("toutiao", 100000005);  //头条预估数据
-                param5.put("aweme", 150000005); //抖音预估数据
-                param5.put("video_app", 40000005);//西瓜预估数据
-                param5.put("hotsoon", 40000005); //火山预估数据
-                param5.put("aweme_account_fans", 0); //账号粉丝相似人群
-                param5.put("auto_extend_enabled", 0);// 智能放量????
-                param5.put("budget_mode", 0);  // 广告预算类型  0 日预算  1 总预算
-                param5.put("budget", requestJson.getString("budgetPrice")); //广告预算
-
-
-                String flowDateType = requestJson.getString("flowDateType");
-                param5.put("schedule_type", 1); //广告投放时间类型   默认1 1:不限  2:按时间???
-                System.err.println(requestJson.getString("startDate"));
-                System.err.println(requestJson.getString("endDate"));
-                param5.put("start_time", "2019-08-03 23:59"); //广告投放起始时间
-                param5.put("end_time", "2019-08-04 23:59");//广告投放结束时间
-
-                List<List<String>> wsList = new ArrayList<List<String>>();
-                wsList.add(new ArrayList<String>());
-                wsList.add(new ArrayList<String>());
-                wsList.add(new ArrayList<String>());
-                wsList.add(new ArrayList<String>());
-                wsList.add(new ArrayList<String>());
-                wsList.add(new ArrayList<String>());
-                wsList.add(new ArrayList<String>());
-                param5.put("week_schedule", wsList);  //投放时段
-                param5.put("week_time", new ArrayList<ArrayList<Integer>>());//投放时段
-                param5.put("pricing", requestJson.getString("priceType")); //计划出价类型  9 按展示付费  7 按点击付费 8 按转化付费
-                param5.put("cpa_phrase", 2); //出价为OCPC时,计划处于哪个阶段??
-                param5.put("is_union_slot", "");
-                param5.put("hide_if_converted", 1); //过滤已转化用户类型字段,只有转化为目标时可填 优化目标为转化才展示
-                param5.put("flow_control_mode", 0); //投放速度/投放方式使用字段
-
-
-                param5.put("smart_bid_type", 0); //自动出价类型,OCPM支持
+                param5.put("package", requestJson.getString("packageName"));
+                param5.put("smart_bid_type", requestJson.getIntValue("bidType")); //自动出价类型,OCPM支持
                 param5.put("adjust_cpa", 0); //是否调整自动出价   允许值: "0", "1"  默认值: 0
                 param5.put("app_bid_ratio", new Object());
-                param5.put("cpa_bid", 1);//目标转化出价
-                param5.put("external_action", 4);//
-                param5.put("android_osv", 0);//
-                List list = new ArrayList();
-                list.add(1);
-
-                param5.put("platform", list);//
-                param5.put("campaign_id", campaignId);*/
-
-                param5.put("name", requestJson.getString("templateName"));//模板名称
-                Integer deliveryRange = requestJson.getInteger("deliveryRange");
-                param5.put("delivery_range", deliveryRange);  //投放形式
-
-                if (deliveryRange == 2) {
-                    param5.put("union_video_type", requestJson.getInteger("deliveryForm")); //投放形式 1:激励视频 2:原生
-                }
-
-                param5.put("classify", requestJson.getString("adCategory")); //广告类别
-                param5.put("projectid", ""); //
-                Integer downloadType = requestJson.getInteger("downloadType");
-                param5.put("download_type", downloadType); //下载方式  1:下载包 2:h5
-                if (downloadType == 1) {
-                    param5.put("download_url",requestJson.getString("downloadUrl"));
-                }
-                if(downloadType == 2 ){
-                    param5.put("external_url", requestJson.getString("externalUrl"));  // 落地页链接
-                }
-
-                param5.put("localGeolocation", new ArrayList<String>());
-                param5.put("package", requestJson.getString("packageName"));//包名
-                param5.put("style_type", 0); //样式类型
-                param5.put("location_type", 4); //受众位置类型
-                param5.put("hide_if_exists", 0); // 过滤已安装,当推广目标为安卓应用下载时可填,0表示不过滤,1表示过滤,默认为不过滤
-                param5.put("interest_tag_mode", 0); //兴趣分类
-                param5.put("token", tokenNode.get("data").get("token").asText());
-                param5.put("toutiao", 100000005);
-                param5.put("aweme", 150000005);
-                param5.put("video_app", 40000005);
-                param5.put("hotsoon", 40000005);
-                param5.put("aweme_account_fans", 0);
-                param5.put("auto_extend_enabled", 0);
-                param5.put("budget_mode", 0); //预算类型 0 日预算  1 总预算
-                param5.put("budget", 300); //预算金额
-                param5.put("app_type", 201); //app 类型 201 应用推广 安卓 201 应用推广 ios
-                param5.put("schedule_type", 1); //广告投放时间类型   默认1 1:不限  2:按时间???
-                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", requestJson.getString("priceType")); ////计划出价类型  9 按展示付费  7 按点击付费 8 按转化付费
-                param5.put("cpa_phrase", 2);
-                param5.put("is_union_slot", "");
-                param5.put("hide_if_converted", 1); //过滤已转化用户类型字段,只有转化为目标时可填 优化目标为转化才展示
-                param5.put("flow_control_mode", 0); //投放速度/投放方式使用字段
-                param5.put("cpa_bid", 1); //目标转化出价
-                param5.put("smart_bid_type", 0); ////自动出价类型,OCPM支持
-
-                param5.put("external_action", 15);
-                param5.put("adjust_cpa", 0); ////是否调整自动出价   允许值: "0", "1"  默认值: 0
-                param5.put("app_bid_ratio", new Object());
-
+                param5.put("name", "自动创建测试b");  //广计划名称
                 param5.put("campaign_id", campaignId);
-
-                System.err.println(JSON.toJSONString(param5));
+                param5.put("app_type", 201); //app 类型 201 应用推广 安卓 201 应用推广 ios
                 String createResult = HttpUtils.httpPostRequest("https://ad.oceanengine.com/overture/ad/create/", param5, header);
                 System.out.println(createResult);
             }

+ 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));
             }
@@ -227,9 +227,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));
             }
@@ -263,14 +263,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();
@@ -358,11 +358,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;
 
@@ -377,10 +377,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();
@@ -425,44 +425,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) {