12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- package com.tzld.piaoquan.longarticle.job;
- import cn.hutool.http.HttpRequest;
- import cn.hutool.http.HttpResponse;
- import com.tzld.piaoquan.longarticle.service.local.impl.MatchVideoServiceImpl;
- import com.tzld.piaoquan.longarticle.utils.LarkRobotUtil;
- import com.xxl.job.core.biz.model.ReturnT;
- import com.xxl.job.core.handler.annotation.XxlJob;
- import lombok.extern.slf4j.Slf4j;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Component;
- import java.net.Authenticator;
- import static com.tzld.piaoquan.longarticle.common.constants.ProxyConstant.PROXY_HOST;
- import static com.tzld.piaoquan.longarticle.common.constants.ProxyConstant.PROXY_PORT;
- @Slf4j
- @Component
- public class MatchVideoJob {
- @Autowired
- MatchVideoServiceImpl matchVideoService;
- @XxlJob("kimiContentJob")
- public ReturnT<String> kimiContentJob(String param) {
- try {
- matchVideoService.kimiContent();
- } catch (Exception e) {
- LarkRobotUtil.sendMessage("kimiContentJob异常,请及时查看,@薛一鸣");
- log.error("kimiContentJob error", e);
- }
- return ReturnT.SUCCESS;
- }
- @XxlJob("matchCrawlerVideo")
- public ReturnT<String> matchCrawlerVideoJob(String param) {
- try {
- matchVideoService.matchCrawlerVideo();
- } catch (Exception e) {
- LarkRobotUtil.sendMessage("matchCrawlerVideoJob异常,请及时查看,@薛一鸣");
- log.error("matchCrawlerVideoJob error", e);
- }
- return ReturnT.SUCCESS;
- }
- @XxlJob("uploadCrawlerVideo")
- public ReturnT<String> uploadCrawlerVideoJob(String param) {
- try {
- matchVideoService.uploadCrawlerVideo();
- } catch (Exception e) {
- LarkRobotUtil.sendMessage("uploadCrawlerVideoJob异常,请及时查看,@薛一鸣");
- log.error("uploadCrawlerVideoJob error", e);
- }
- return ReturnT.SUCCESS;
- }
- @XxlJob("publishCrawlerVideo")
- public ReturnT<String> publishCrawlerVideoJob(String param) {
- try {
- matchVideoService.publishCrawlerVideo();
- } catch (Exception e) {
- LarkRobotUtil.sendMessage("publishCrawlerVideoJob异常,请及时查看,@薛一鸣");
- log.error("publishCrawlerVideoJob error", e);
- }
- return ReturnT.SUCCESS;
- }
- @XxlJob("testJob")
- public ReturnT<String> testJob(String param) {
- // 目标网站
- String url = "https://www.baidu.com";
- // 发送请求
- HttpResponse result = HttpRequest.get(url)
- .setHttpProxy(PROXY_HOST, PROXY_PORT)
- .timeout(20000)//设置超时,毫秒
- .execute();
- log.info("test={}", result.body());
- return ReturnT.SUCCESS;
- }
- }
|