Преглед на файлове

添加chrome-driver配置参数信息

syh преди 5 години
родител
ревизия
f04bfca9a9

+ 1 - 1
jeecg-boot-module-system/src/main/resources/application-wps.yml

@@ -143,7 +143,7 @@ jeecg:
     webapp: /mnt/webapp
     video-upload: /mnt/upload/video/
     image-upload: /mnt/upload/image/
-    chrome-driver: /usr/bin/chromedriver
+    chrome-driver: D://chromedriver.exe
     csv-upload: /mnt/upload/csv/
     bak-database-file: /mnt/data/bak/
     report-history: /mnt/upload/report/history/

+ 0 - 12
jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java

@@ -11,7 +11,6 @@ import cn.com.ctop.crawler.modules.pangolin.entity.PangolinApp;
 import cn.com.ctop.crawler.modules.pangolin.service.PangolinAppService;
 import cn.com.ctop.crawler.modules.pangolin.service.PangolinCrawlerService;
 import cn.com.ctop.crawler.modules.pangolin.service.PangolinLoginService;
-import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouDailyReportTaskService;
 import cn.com.ctop.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService;
 import cn.com.ctop.toutiao.modules.report.service.IByteDanceVideoReportDailyService;
 import cn.com.ctop.toutiao.modules.report.service.IBytedanceReportService;
@@ -153,17 +152,6 @@ public class SampleTest {
             }
         }
     }
-
-    @Autowired
-    private IKuaiShouDailyReportTaskService dailyReportTaskService;
-    @Test
-    public void testLoadKuaishouData(){
-        CtopOauthToken token = oauthTokenService.getTokenByAccountId(4801739L);
-        for(int i=0;i<50;i++){
-            Date startDate = DateUtils.addDay(new Date(),-(i+30));
-            dailyReportTaskService.getTaskList(token.getAccountId(), token.getAccessToken(), DateUtils.formatDate(startDate));
-        }
-    }
 }
 
 

+ 3 - 3
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IKuaishouReportDailyAgentService.java

@@ -12,7 +12,7 @@ import java.util.List;
  * @version V1.0
  */
 public interface IKuaishouReportDailyAgentService extends IService<KuaishouReportDailyAgent> {
-    public void replaceBatch(List<KuaishouReportDailyAgent> list);
-    public void getReport(String startDate,String endDate);
-    public boolean getAccount(int currentPage);
+    void replaceBatch(List<KuaishouReportDailyAgent> list);
+    void getReport(String startDate,String endDate);
+    boolean getAccount(int currentPage);
 }

+ 8 - 12
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouReportDailyAgentServiceImpl.java

@@ -14,7 +14,6 @@ import com.fasterxml.jackson.databind.DeserializationFeature;
 import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import lombok.extern.slf4j.Slf4j;
-import org.apache.http.client.CookieStore;
 import org.apache.http.impl.client.BasicCookieStore;
 import org.apache.http.impl.cookie.BasicClientCookie;
 import org.jeecg.common.util.DateUtils;
@@ -63,6 +62,7 @@ public class KuaishouReportDailyAgentServiceImpl extends ServiceImpl<KuaishouRep
         ChromeOptions chromeOptions = new ChromeOptions();
         chromeOptions.addArguments("--headless");
         chromeOptions.addArguments("--incognito");
+        chromeOptions.addArguments("--disable-dev-shm-usage");
         chromeOptions.addArguments("--disable-gpu");
         chromeOptions.addArguments("--window-size=1920,1080");
         chromeOptions.addArguments("--user-agent=" + HttpUtils2.USER_AGENT);
@@ -88,11 +88,10 @@ public class KuaishouReportDailyAgentServiceImpl extends ServiceImpl<KuaishouRep
 
             Set<Cookie> cookies = webDriver.manage().getCookies();
             Iterator iterator = cookies.iterator();
-            CookieStore cookieStore = new BasicCookieStore();
             while (iterator.hasNext()) {
                 String cookieStr = iterator.next().toString();
                 String[] cookieArray = cookieStr.split(";");
-                Map<String, String> cookieMap = new HashMap<String, String>();
+                Map<String, String> cookieMap = new HashMap<>();
                 for (String cookie : cookieArray) {
                     String[] kv = cookie.split("=");
                     if (kv.length > 1) {
@@ -111,7 +110,6 @@ public class KuaishouReportDailyAgentServiceImpl extends ServiceImpl<KuaishouRep
             loginStatus = false;
         } finally {
             webDriver.manage().deleteAllCookies();
-//            webDriver.close();
             webDriver.quit();
         }
         return loginStatus;
@@ -121,12 +119,10 @@ public class KuaishouReportDailyAgentServiceImpl extends ServiceImpl<KuaishouRep
     public boolean getAccount(int currentPage) {
         boolean hasNextPage = false;
         try {
-            if (currentPage == 1) {
-                if (!loginAgent()) {
-                    return hasNextPage;
-                }
+            if (currentPage == 1&&!loginAgent()) {
+                return hasNextPage;
             }
-            Map<String, String> headerMap = new HashMap<String, String>();
+            Map<String, String> headerMap = new HashMap<>();
             headerMap.put("Accept", "application/json");
             headerMap.put("Accept-Encoding", "gzip, deflate, br");
             headerMap.put("Accept-Language", "zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2");
@@ -162,7 +158,7 @@ public class KuaishouReportDailyAgentServiceImpl extends ServiceImpl<KuaishouRep
                     agentAccount.setTotalBalance(agentAccount.getTotalBalance().divide(new BigDecimal(1000)));
                     accountList.add(agentAccount);
                 }
-                if (accountList != null && accountList.size() > 0) {
+                if (!accountList.isEmpty()) {
                     kuaishouAgentAccountMapper.replaceBatch(accountList);
                 }
             }
@@ -180,7 +176,7 @@ public class KuaishouReportDailyAgentServiceImpl extends ServiceImpl<KuaishouRep
                 return;
             }
             String currentDate = startDate;
-            Map<String, String> headerMap = new HashMap<String, String>();
+            Map<String, String> headerMap = new HashMap<>();
             headerMap.put("Accept", "application/json");
             headerMap.put("Accept-Encoding", "gzip, deflate, br");
             headerMap.put("Accept-Language", "zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2");
@@ -250,7 +246,7 @@ public class KuaishouReportDailyAgentServiceImpl extends ServiceImpl<KuaishouRep
                         }
                         i++;
                     }
-                    if (reportList != null && reportList.size() > 0) {
+                    if (!reportList.isEmpty()) {
                         replaceBatch(reportList);
                     }
                 }