123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- package org.jeecg;
- import cn.com.ctop.common.module.entity.BindAccountLogin;
- import cn.com.ctop.common.module.service.IBindAccountLoginService;
- import cn.com.ctop.common.module.utils.CtopAdConstant;
- import cn.com.ctop.crawler.modules.oceanengine.entity.HotMaterial;
- import cn.com.ctop.crawler.modules.oceanengine.service.IHotMaterialService;
- import cn.com.ctop.crawler.modules.oceanengine.service.IOceanEngineService;
- import cn.com.ctop.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService;
- import lombok.extern.slf4j.Slf4j;
- import org.junit.Test;
- import org.junit.runner.RunWith;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.boot.test.context.SpringBootTest;
- import org.springframework.test.context.junit4.SpringRunner;
- import java.util.HashMap;
- import java.util.List;
- import java.util.concurrent.CountDownLatch;
- import java.util.concurrent.ExecutorService;
- import java.util.concurrent.Executors;
- @RunWith(SpringRunner.class)
- @SpringBootTest
- @Slf4j
- public class SampleTest {
- @Autowired
- private IOceanEngineService oceanEngineService;
- @Autowired
- private IHotMaterialService hotMaterialService;
- @Test
- public void initImageUrl(){
- List<HotMaterial> hotMaterials = hotMaterialService.getId();
- if(null!=hotMaterials&&!hotMaterials.isEmpty()){
- hotMaterials.forEach(douyinHot -> {
- HotMaterial getHot = hotMaterialService.getById(douyinHot.getId());
- // String image = getHot.getCoverImage().replace("data:image/jpg;base64,", "");
- String destPath = "D:\\data\\effectCase\\";
- String fileName = getHot.getId()+".jpg";
- // EffectCase.base64ToFile(destPath,image,fileName);
- });
- }
- }
- @Test
- public void testOceanEngineJob(){
- String account="3248395570@qq.com";
- String password = "Ydxq-704127411";
- oceanEngineService.login(account,password);
- oceanEngineService.douyinHotHandler(1,1);
- oceanEngineService.effectCaseHandler(1);
- oceanEngineService.hotMaterialHandler(1,4,"抖音");
- oceanEngineService.hotMaterialHandler(1,8,"头条");
- oceanEngineService.hotMaterialHandler(1,1,"西瓜");
- oceanEngineService.hotMaterialHandler(1,3,"火山");
- oceanEngineService.hotMaterialHandler(1,9,"穿山甲");
- log.info("巨量创意抓取完成");
- }
- @Autowired
- private IBindAccountLoginService bindAccountLoginService;
- @Autowired
- private IKuaishouWebInterfaceService kuaishouWebInterfaceService;
- @Test
- public void kuaishouLogin(){
- Long start =System.currentTimeMillis();
- List<BindAccountLogin> list = bindAccountLoginService.getListByParams(CtopAdConstant.PLATFORM_TYPE_KUAISHOU_PY,1);
- if(list!=null&&!list.isEmpty()){
- for (BindAccountLogin login:list) {
- if(null==login.getCookie()||"".equals(login.getCookie().trim())){
- kuaishouWebInterfaceService.getkuaishouWebLoginCookie(login);
- }
- }
- }
- Long end = System.currentTimeMillis();
- log.info("总用时:{}毫秒",end-start);
- }
- static ExecutorService executorService = null;
- static CountDownLatch countDownLatch = null;
- @Test
- public void kuaishouCommentDelete(){
- Long start =System.currentTimeMillis();
- List<BindAccountLogin> list = bindAccountLoginService.getListByParams(CtopAdConstant.PLATFORM_TYPE_KUAISHOU_PY,1);
- if(list!=null&&!list.isEmpty()){
- executorService = Executors.newFixedThreadPool(10);
- countDownLatch = new CountDownLatch(list.size());
- list.forEach(login -> {
- executorService.submit(()->{
- try {
- if(null!=login.getCookie()&&!"".equals(login.getCookie().trim())){
- kuaishouWebInterfaceService.deleteAllComment(new HashMap<>(),login);
- }
- }catch (Exception e){
- }finally {
- countDownLatch.countDown();
- }
- });
- });
- }
- try {
- countDownLatch.await();
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- Long end = System.currentTimeMillis();
- log.info("总用时:{}毫秒",end-start);
- }
- @Test
- public void testBase64(){
- }
- }
- //刷新token:885936毫秒
|