123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229 |
- package org.jeecg;
- import cn.com.ctop.bytedance.service.IByteDanceHourlyAccountWarningService;
- import cn.com.ctop.bytedance.service.IReportService;
- import cn.com.ctop.common.module.entity.CtopOauthToken;
- import cn.com.ctop.common.module.mapper.CtopOauthTokenMapper;
- import cn.com.ctop.common.module.service.ICtopOauthTokenService;
- import cn.com.ctop.common.module.utils.CtopAdConstant;
- import cn.com.ctop.common.module.utils.HttpUtils2;
- import cn.com.ctop.crawler.modules.appium.service.IAppiumJobService;
- import cn.com.ctop.crawler.modules.appium.service.IAppiumTaskService;
- import cn.com.ctop.kuaishou.modules.batch.service.IAccountWarningService;
- import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
- import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
- import lombok.extern.slf4j.Slf4j;
- import org.apache.http.impl.client.BasicCookieStore;
- import org.jeecg.common.util.DateUtils;
- import org.jeecg.modules.ctop.service.IBidWarningService;
- import org.jeecg.modules.ctop.service.ICreateInternalService;
- import org.jeecg.modules.mq.Sender;
- import org.junit.Test;
- import org.junit.runner.RunWith;
- import org.openqa.selenium.By;
- import org.openqa.selenium.JavascriptExecutor;
- import org.openqa.selenium.WebDriver;
- import org.openqa.selenium.WebElement;
- import org.openqa.selenium.chrome.ChromeDriver;
- import org.openqa.selenium.chrome.ChromeOptions;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.beans.factory.annotation.Value;
- import org.springframework.boot.test.context.SpringBootTest;
- import org.springframework.test.context.junit4.SpringRunner;
- import java.text.SimpleDateFormat;
- import java.util.Date;
- import java.util.List;
- import java.util.concurrent.ExecutorService;
- import java.util.concurrent.Executors;
- @RunWith(SpringRunner.class)
- @SpringBootTest
- @Slf4j
- public class SampleTest {
- @Value("${jeecg.path.chrome-driver}")
- private String chromeDriver;
- @Autowired
- private IAppiumJobService jobService;
- @Autowired
- private ICreateInternalService createInternalService;
- @Autowired
- private IAppiumTaskService appiumTaskService;
- @Test
- public void testKs() throws InterruptedException {
- String url = "https://ad.e.kuaishou.com/#/welcome?redirectUrl=https%3A%2F%2Fad.e.kuaishou.com%2F%23%2Findex";
- System.getProperties().setProperty("webdriver.chrome.driver", chromeDriver);
- ChromeOptions chromeOptions = new ChromeOptions();
- // chromeOptions.addArguments("--headless");
- chromeOptions.addArguments("--incognito");
- chromeOptions.addArguments("--disable-gpu");
- // chromeOptions.addArguments("--no-sandbox");
- chromeOptions.addArguments("--window-size=1920,1080");
- chromeOptions.addArguments("--user-agent=" + HttpUtils2.USER_AGENT);
- chromeOptions.setAcceptInsecureCerts(true);
- WebDriver webDriver = new ChromeDriver(chromeOptions);
- try {
- Thread.sleep(3000L);
- HttpUtils2.cookieStore = new BasicCookieStore();
- webDriver.manage().deleteAllCookies();
- //获取登录页面
- webDriver.get(url);
- Thread.sleep(3000L);
- WebElement accountElement = webDriver.findElement(By.xpath("//div[@class='phone ']/input[@type='text']"));
- accountElement.sendKeys("19845004383");
- Thread.sleep(3000L);
- WebElement passwordElement = webDriver.findElement(By.xpath("//div[@class='password ']/input[@type='password']"));
- passwordElement.sendKeys("a123456");
- WebElement loginElement = webDriver.findElement(By.xpath("//div[@class='foot']"));
- Thread.sleep(3000L);
- //点击登录
- loginElement.click();
- Thread.sleep(3000L);
- //获取推广按钮
- WebElement spreadElement = webDriver.findElement(By.linkText("推广"));
- spreadElement.click();
- Thread.sleep(3000L);
- //选择广告创意
- WebElement creativeElement = webDriver.findElement(By.xpath("//div[text()='广告创意']"));
- creativeElement.click();
- Thread.sleep(3000L);
- //输入创意名称,点击搜索
- WebElement searchElement = webDriver.findElement(By.xpath("//input[@type='text']"));
- searchElement.sendKeys("2-这个是你画的吗-设计-11.19");
- Thread.sleep(3000L);
- WebElement searchButton = webDriver.findElement(By.xpath("//button[@class='ant-btn ant-input-search-button ant-btn-primary']"));
- searchButton.click();
- Thread.sleep(3000L);
- WebElement tiyanElement = webDriver.findElement(By.linkText("体验"));
- tiyanElement.click();
- Thread.sleep(2000L);
- WebElement inputKsIdElement = webDriver.findElement(By.xpath("//textarea[@placeholder='请输入快手账号…']"));
- inputKsIdElement.sendKeys("123456765");
- Thread.sleep(2000L);
- WebElement chufaElement = webDriver.findElement(By.xpath("//button[@class='creative-experience-btn-enable']"));
- chufaElement.click();
- } catch (Exception e) {
- e.printStackTrace();
- webDriver.manage().deleteAllCookies();
- webDriver.close();
- }
- }
- @Test
- public void test() {
- jobService.refreshWebPhone();
- }
- @Test
- public void testMq() {
- Sender sender = new Sender();
- sender.send();
- }
- @Test
- public void loadKuaishouDataSingle() throws Exception {
- String url = "https://a201903112120030590198943.szwego.com/static/index.html#/shop_detail/A201903112120030590198943";
- System.getProperties().setProperty("webdriver.chrome.driver", chromeDriver);
- ChromeOptions chromeOptions = new ChromeOptions();
- // chromeOptions.addArguments("--headless");
- chromeOptions.addArguments("--incognito");
- chromeOptions.addArguments("--disable-gpu");
- // chromeOptions.addArguments("--no-sandbox");
- chromeOptions.addArguments("--window-size=1920,1080");
- chromeOptions.addArguments("--user-agent=" + HttpUtils2.USER_AGENT);
- chromeOptions.setAcceptInsecureCerts(true);
- WebDriver webDriver = new ChromeDriver(chromeOptions);
- webDriver.get(url);
- Thread.sleep(3000L);
- ((JavascriptExecutor) webDriver).executeScript("window.scrollTo(0,document.body.scrollHeight)");
- Thread.sleep(3000L);
- List<WebElement> elementList = webDriver.findElements(By.xpath("//div[@class='word-break ellipsis-two f14 g3']"));
- for (WebElement element : elementList) {
- System.out.println(element.getText());
- }
- }
- @Autowired
- private IKuaishouInterfaceService kuaishouInterfaceService;
- @Test
- public void testMail() throws Exception {
- // String accessToken, Long advertiserId, Date startDate, Date endDate, Integer page
- kuaishouInterfaceService.getTargetingTags(23212L, "101a5c994d0a87322f305a306a30e38e");
- }
- @Autowired
- private IBidWarningService bidWarningService;
- @Autowired
- private IAccountWarningService accountWarningService;
- @Autowired
- private CtopOauthTokenMapper oauthTokenMapper;
- static ExecutorService executorService = Executors.newFixedThreadPool(5);
- @Test
- public void testMa() throws Exception {
- // accountWarningService.accountWarning(23212L);
- QueryWrapper<CtopOauthToken> oauthTokenQueryWrapper = new QueryWrapper<>();
- oauthTokenQueryWrapper.eq("media_id", 2);
- List<CtopOauthToken> ctopOauthTokens = oauthTokenMapper.selectList(oauthTokenQueryWrapper);
- for (CtopOauthToken token : ctopOauthTokens) {
- kuaishouInterfaceService.getCreativeList(token, null, null);
- }
- }
- @Autowired
- private ICtopOauthTokenService tokenService;
- @Autowired
- private IReportService reportService;
- @Autowired
- private IByteDanceHourlyAccountWarningService byteDanceHourlyAccountWarningService;
- @Test
- public void testMa2() throws Exception {
- byteDanceHourlyAccountWarningService.byteDanceAccountWarning(1655337394471943L,"2020-02-06","2020-02-05");
- /*Date getDate = new Date();
- SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH");
- String hour = simpleDateFormat.format(getDate);
- if (null != hour && "00".equals(hour)) {
- getDate = DateUtils.addDay(getDate, -1);
- }
- //1:查询当日数据
- List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_BYTEDANCE);
- if (null == tokens || tokens.size() <= 0) {
- log.info("定时获取头条小时数据异常:未获取到可用的token");
- return;
- }
- Date finalGetDate = getDate;
- QueryWrapper<CtopOauthToken> oauthTokenQueryWrapper = new QueryWrapper<>();
- oauthTokenQueryWrapper.eq("account_id", 1655337394471943L);
- CtopOauthToken ctopOauthToken = oauthTokenMapper.selectOne(oauthTokenQueryWrapper);*/
- //1: 获取广告主信息数据
- // reportService.getAdvertiserReport(ctopOauthToken, finalGetDate, finalGetDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY);
- //2:获取广告组信息数据
- //reportService.getAdvertiserCampaignReport(token, finalGetDate, finalGetDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY);
- //3:获取广告计划信息数据
- //reportService.getAdvertiserPlanReport(token, finalGetDate, finalGetDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY);
- //4: 获取广告创意信息数据
- //reportService.getAdvertiserCreativeReport(token, finalGetDate, finalGetDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY);
- }
- }
|