MatchVideoJob.java 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. package com.tzld.piaoquan.longarticle.job;
  2. import cn.hutool.http.HttpRequest;
  3. import cn.hutool.http.HttpResponse;
  4. import com.tzld.piaoquan.longarticle.service.local.impl.MatchVideoServiceImpl;
  5. import com.tzld.piaoquan.longarticle.utils.LarkRobotUtil;
  6. import com.xxl.job.core.biz.model.ReturnT;
  7. import com.xxl.job.core.handler.annotation.XxlJob;
  8. import lombok.extern.slf4j.Slf4j;
  9. import org.springframework.beans.factory.annotation.Autowired;
  10. import org.springframework.stereotype.Component;
  11. import java.net.Authenticator;
  12. import static com.tzld.piaoquan.longarticle.common.constants.ProxyConstant.PROXY_HOST;
  13. import static com.tzld.piaoquan.longarticle.common.constants.ProxyConstant.PROXY_PORT;
  14. @Slf4j
  15. @Component
  16. public class MatchVideoJob {
  17. @Autowired
  18. MatchVideoServiceImpl matchVideoService;
  19. @XxlJob("kimiContentJob")
  20. public ReturnT<String> kimiContentJob(String param) {
  21. try {
  22. matchVideoService.kimiContent();
  23. } catch (Exception e) {
  24. LarkRobotUtil.sendMessage("kimiContentJob异常,请及时查看,@薛一鸣");
  25. log.error("kimiContentJob error", e);
  26. }
  27. return ReturnT.SUCCESS;
  28. }
  29. @XxlJob("matchCrawlerVideo")
  30. public ReturnT<String> matchCrawlerVideoJob(String param) {
  31. try {
  32. matchVideoService.matchCrawlerVideo();
  33. } catch (Exception e) {
  34. LarkRobotUtil.sendMessage("matchCrawlerVideoJob异常,请及时查看,@薛一鸣");
  35. log.error("matchCrawlerVideoJob error", e);
  36. }
  37. return ReturnT.SUCCESS;
  38. }
  39. @XxlJob("uploadCrawlerVideo")
  40. public ReturnT<String> uploadCrawlerVideoJob(String param) {
  41. try {
  42. matchVideoService.uploadCrawlerVideo();
  43. } catch (Exception e) {
  44. LarkRobotUtil.sendMessage("uploadCrawlerVideoJob异常,请及时查看,@薛一鸣");
  45. log.error("uploadCrawlerVideoJob error", e);
  46. }
  47. return ReturnT.SUCCESS;
  48. }
  49. @XxlJob("publishCrawlerVideo")
  50. public ReturnT<String> publishCrawlerVideoJob(String param) {
  51. try {
  52. matchVideoService.publishCrawlerVideo();
  53. } catch (Exception e) {
  54. LarkRobotUtil.sendMessage("publishCrawlerVideoJob异常,请及时查看,@薛一鸣");
  55. log.error("publishCrawlerVideoJob error", e);
  56. }
  57. return ReturnT.SUCCESS;
  58. }
  59. @XxlJob("testJob")
  60. public ReturnT<String> testJob(String param) {
  61. // 目标网站
  62. String url = "https://www.baidu.com";
  63. // 发送请求
  64. HttpResponse result = HttpRequest.get(url)
  65. .setHttpProxy(PROXY_HOST, PROXY_PORT)
  66. .timeout(20000)//设置超时,毫秒
  67. .execute();
  68. log.info("test={}", result.body());
  69. return ReturnT.SUCCESS;
  70. }
  71. }