SampleTest.java 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. package org.jeecg;
  2. import cn.com.ctop.common.module.entity.BindAccountLogin;
  3. import cn.com.ctop.common.module.service.IBindAccountLoginService;
  4. import cn.com.ctop.common.module.utils.CtopAdConstant;
  5. import cn.com.ctop.crawler.modules.oceanengine.service.IOceanEngineService;
  6. import cn.com.ctop.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService;
  7. import lombok.extern.slf4j.Slf4j;
  8. import org.junit.Test;
  9. import org.junit.runner.RunWith;
  10. import org.springframework.beans.factory.annotation.Autowired;
  11. import org.springframework.boot.test.context.SpringBootTest;
  12. import org.springframework.test.context.junit4.SpringRunner;
  13. import java.util.HashMap;
  14. import java.util.List;
  15. import java.util.concurrent.CountDownLatch;
  16. import java.util.concurrent.ExecutorService;
  17. import java.util.concurrent.Executors;
  18. @RunWith(SpringRunner.class)
  19. @SpringBootTest
  20. @Slf4j
  21. public class SampleTest {
  22. @Autowired
  23. private IOceanEngineService oceanEngineService;
  24. @Test
  25. public void testOceanEngineJob(){
  26. String account="3248395570@qq.com";
  27. String password = "Ydxq-704127411";
  28. oceanEngineService.login(account,password);
  29. oceanEngineService.douyinHotHandler(1,1);
  30. oceanEngineService.effectCaseHandler(1);
  31. oceanEngineService.hotMaterialHandler(1,4,"抖音");
  32. oceanEngineService.hotMaterialHandler(1,8,"头条");
  33. oceanEngineService.hotMaterialHandler(1,1,"西瓜");
  34. oceanEngineService.hotMaterialHandler(1,3,"火山");
  35. oceanEngineService.hotMaterialHandler(1,9,"穿山甲");
  36. log.info("巨量创意抓取完成");
  37. }
  38. @Autowired
  39. private IBindAccountLoginService bindAccountLoginService;
  40. @Autowired
  41. private IKuaishouWebInterfaceService kuaishouWebInterfaceService;
  42. @Test
  43. public void kuaishouLogin(){
  44. Long start =System.currentTimeMillis();
  45. List<BindAccountLogin> list = bindAccountLoginService.getListByParams(CtopAdConstant.PLATFORM_TYPE_KUAISHOU_PY,1);
  46. if(list!=null&&!list.isEmpty()){
  47. for (BindAccountLogin login:list) {
  48. if(null==login.getCookie()||"".equals(login.getCookie().trim())){
  49. kuaishouWebInterfaceService.getkuaishouWebLoginCookie(login);
  50. }
  51. }
  52. }
  53. Long end = System.currentTimeMillis();
  54. log.info("总用时:{}毫秒",end-start);
  55. }
  56. static ExecutorService executorService = null;
  57. static CountDownLatch countDownLatch = null;
  58. @Test
  59. public void kuaishouCommentDelete(){
  60. Long start =System.currentTimeMillis();
  61. List<BindAccountLogin> list = bindAccountLoginService.getListByParams(CtopAdConstant.PLATFORM_TYPE_KUAISHOU_PY,1);
  62. if(list!=null&&!list.isEmpty()){
  63. executorService = Executors.newFixedThreadPool(10);
  64. countDownLatch = new CountDownLatch(list.size());
  65. list.forEach(login -> {
  66. executorService.submit(()->{
  67. try {
  68. if(null!=login.getCookie()&&!"".equals(login.getCookie().trim())){
  69. kuaishouWebInterfaceService.deleteAllComment(new HashMap<>(),login);
  70. }
  71. }catch (Exception e){
  72. }finally {
  73. countDownLatch.countDown();
  74. }
  75. });
  76. });
  77. }
  78. try {
  79. countDownLatch.await();
  80. } catch (InterruptedException e) {
  81. e.printStackTrace();
  82. }
  83. Long end = System.currentTimeMillis();
  84. log.info("总用时:{}毫秒",end-start);
  85. }
  86. }
  87. //刷新token:885936毫秒