|
@@ -1,21 +1,17 @@
|
|
package org.jeecg;
|
|
package org.jeecg;
|
|
|
|
|
|
-import cn.com.ctop.common.module.entity.CtopOauthToken;
|
|
|
|
-import cn.com.ctop.common.module.mapper.CtopOauthTokenMapper;
|
|
|
|
import cn.com.ctop.common.module.utils.HttpUtils2;
|
|
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.IAppiumJobService;
|
|
import cn.com.ctop.crawler.modules.appium.service.IAppiumTaskService;
|
|
import cn.com.ctop.crawler.modules.appium.service.IAppiumTaskService;
|
|
-import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
|
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.apache.http.impl.client.BasicCookieStore;
|
|
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.IBidWarningService;
|
|
import org.jeecg.modules.ctop.service.ICreateInternalService;
|
|
import org.jeecg.modules.ctop.service.ICreateInternalService;
|
|
import org.jeecg.modules.mq.Sender;
|
|
import org.jeecg.modules.mq.Sender;
|
|
import org.junit.Test;
|
|
import org.junit.Test;
|
|
import org.junit.runner.RunWith;
|
|
import org.junit.runner.RunWith;
|
|
import org.openqa.selenium.By;
|
|
import org.openqa.selenium.By;
|
|
|
|
+import org.openqa.selenium.JavascriptExecutor;
|
|
import org.openqa.selenium.WebDriver;
|
|
import org.openqa.selenium.WebDriver;
|
|
import org.openqa.selenium.WebElement;
|
|
import org.openqa.selenium.WebElement;
|
|
import org.openqa.selenium.chrome.ChromeDriver;
|
|
import org.openqa.selenium.chrome.ChromeDriver;
|
|
@@ -25,15 +21,7 @@ import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.boot.test.context.SpringBootTest;
|
|
import org.springframework.boot.test.context.SpringBootTest;
|
|
import org.springframework.test.context.junit4.SpringRunner;
|
|
import org.springframework.test.context.junit4.SpringRunner;
|
|
|
|
|
|
-import javax.mail.Message;
|
|
|
|
-import javax.mail.Session;
|
|
|
|
-import javax.mail.Transport;
|
|
|
|
-import javax.mail.internet.InternetAddress;
|
|
|
|
-import javax.mail.internet.MimeMessage;
|
|
|
|
-import java.util.ArrayList;
|
|
|
|
-import java.util.Date;
|
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
-import java.util.Properties;
|
|
|
|
|
|
|
|
@RunWith(SpringRunner.class)
|
|
@RunWith(SpringRunner.class)
|
|
@SpringBootTest
|
|
@SpringBootTest
|
|
@@ -121,93 +109,33 @@ public class SampleTest {
|
|
sender.send();
|
|
sender.send();
|
|
}
|
|
}
|
|
|
|
|
|
- @Autowired
|
|
|
|
- private IKuaishouInterfaceService kuaishouInterfaceService;
|
|
|
|
- @Autowired
|
|
|
|
- private CtopOauthTokenMapper tokenMapper;
|
|
|
|
-
|
|
|
|
@Test
|
|
@Test
|
|
- public void loadKuaishouDataSingle() {
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- Date endDate = new Date();
|
|
|
|
- QueryWrapper<CtopOauthToken> tokenQueryWrapper = new QueryWrapper<>();
|
|
|
|
- tokenQueryWrapper.eq("media_id", 2);
|
|
|
|
- List<CtopOauthToken> ctopOauthTokens = tokenMapper.selectList(tokenQueryWrapper);
|
|
|
|
- for (CtopOauthToken token : ctopOauthTokens) {
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- for (int i = 0; i < 7; i++) {
|
|
|
|
- Date getStartDate = DateUtils.addDay(endDate, -i);
|
|
|
|
-
|
|
|
|
- //3:获取广告组信息数据
|
|
|
|
- kuaishouInterfaceService.getAdvertiserGroupReportHourly(token, getStartDate, getStartDate);
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- for (int i = 0; i < 6; i++) {
|
|
|
|
- Date getStartDate = new Date();
|
|
|
|
- Date getEndDate = new Date();
|
|
|
|
- if (i == 0) {
|
|
|
|
- getStartDate = DateUtils.addDay(endDate, -175 + i * 30);
|
|
|
|
- getEndDate = DateUtils.addDay(endDate, -150 + i * 30);
|
|
|
|
- } else {
|
|
|
|
- getStartDate = DateUtils.addDay(endDate, -180 + i * 30);
|
|
|
|
- getEndDate = DateUtils.addDay(endDate, -150 + i * 30);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //3:获取广告组信息数据
|
|
|
|
- kuaishouInterfaceService.getAdvertiserGroupReportDaily(token, getStartDate, getEndDate);
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+ 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());
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@Test
|
|
@Test
|
|
public void testMail() throws Exception {
|
|
public void testMail() throws Exception {
|
|
- Properties properties = new Properties();
|
|
|
|
- properties.put("mail.transport.protocol", "smtp");// 连接协议
|
|
|
|
- properties.put("mail.smtp.host", "smtp.exmail.qq.com");// 主机名
|
|
|
|
- properties.put("mail.smtp.port", 465);// 端口号
|
|
|
|
- properties.put("mail.smtp.auth", "true");
|
|
|
|
- properties.put("mail.smtp.ssl.enable", "true");// 设置是否使用ssl安全连接 ---一般都使用
|
|
|
|
- properties.put("mail.debug", "true");// 设置是否显示debug信息 true 会在控制台显示相关信息
|
|
|
|
- // 得到回话对象
|
|
|
|
- Session session = Session.getInstance(properties);
|
|
|
|
- // 获取邮件对象
|
|
|
|
- Message message = new MimeMessage(session);
|
|
|
|
- // 设置发件人邮箱地址
|
|
|
|
- message.setFrom(new InternetAddress("notice@c-top.com.cn"));
|
|
|
|
- // 设置收件人邮箱地址
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- List<String> mails = new ArrayList<>();
|
|
|
|
- mails.add("yumengmeng@c-top.com.cn");
|
|
|
|
- mails.add("zhuxinbo@c-top.com.cn");
|
|
|
|
-
|
|
|
|
- InternetAddress[] internetAddresses = new InternetAddress[mails.size()];
|
|
|
|
- for (int i = 0; i < mails.size(); i++) {
|
|
|
|
- InternetAddress addr = new InternetAddress(mails.get(i));
|
|
|
|
- internetAddresses[i] = addr;
|
|
|
|
- }
|
|
|
|
|
|
|
|
- message.setRecipients(Message.RecipientType.TO, internetAddresses);
|
|
|
|
- // message.setRecipients(Message.RecipientType.TO, new InternetAddress[]{new InternetAddress("yumengmeng@c-top.com.cn"),new InternetAddress("zhuxinbo@c-top.com.cn")});
|
|
|
|
- //message.setRecipient(Message.RecipientType.TO, new InternetAddress("xxx@qq.com"));//一个收件人
|
|
|
|
- // 设置邮件标题
|
|
|
|
- message.setSubject("测试邮件");
|
|
|
|
- // 设置邮件内容
|
|
|
|
- message.setText("你好啊");
|
|
|
|
- // 得到邮差对象
|
|
|
|
- Transport transport = session.getTransport();
|
|
|
|
- // 连接自己的邮箱账户
|
|
|
|
- transport.connect("notice@c-top.com.cn", "Hcst@2019");// 密码为QQ邮箱开通的stmp服务后得到的客户端授权码
|
|
|
|
- // 发送邮件
|
|
|
|
- transport.sendMessage(message, message.getAllRecipients());
|
|
|
|
- transport.close();
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|