|
@@ -11,13 +11,11 @@ import org.jsoup.nodes.Document;
|
|
|
import org.jsoup.nodes.Element;
|
|
import org.jsoup.nodes.Element;
|
|
|
import org.jsoup.select.Elements;
|
|
import org.jsoup.select.Elements;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
-import org.springframework.scheduling.annotation.Async;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
import top.lvzhiqiang.entity.VideoMonitorActors;
|
|
import top.lvzhiqiang.entity.VideoMonitorActors;
|
|
|
import top.lvzhiqiang.mapper.VideoMonitorActorsMapper;
|
|
import top.lvzhiqiang.mapper.VideoMonitorActorsMapper;
|
|
|
import top.lvzhiqiang.service.Crawler4JavdbService;
|
|
import top.lvzhiqiang.service.Crawler4JavdbService;
|
|
|
import top.lvzhiqiang.util.JsoupUtil;
|
|
import top.lvzhiqiang.util.JsoupUtil;
|
|
|
-import top.lvzhiqiang.util.SpringUtils;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
import java.net.InetSocketAddress;
|
|
import java.net.InetSocketAddress;
|
|
@@ -26,6 +24,9 @@ import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
|
+import java.util.concurrent.ScheduledExecutorService;
|
|
|
|
|
+import java.util.concurrent.ScheduledThreadPoolExecutor;
|
|
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Crawler Javdb ServiceImpl
|
|
* Crawler Javdb ServiceImpl
|
|
@@ -46,6 +47,8 @@ public class Crawler4JavdbServiceImpl implements Crawler4JavdbService {
|
|
|
|
|
|
|
|
//private final ForkJoinPool forkJoinPool = new ForkJoinPool(16);
|
|
//private final ForkJoinPool forkJoinPool = new ForkJoinPool(16);
|
|
|
|
|
|
|
|
|
|
+ private final static ScheduledExecutorService scheduler = new ScheduledThreadPoolExecutor(10);
|
|
|
|
|
+
|
|
|
private static final WxCpServiceImpl wxCpService;
|
|
private static final WxCpServiceImpl wxCpService;
|
|
|
static {
|
|
static {
|
|
|
WxCpDefaultConfigImpl wxCpDefaultConfig = new WxCpDefaultConfigImpl();
|
|
WxCpDefaultConfigImpl wxCpDefaultConfig = new WxCpDefaultConfigImpl();
|
|
@@ -68,62 +71,64 @@ public class Crawler4JavdbServiceImpl implements Crawler4JavdbService {
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public void monitorActors() {
|
|
public void monitorActors() {
|
|
|
- beforeJavbus();
|
|
|
|
|
-
|
|
|
|
|
- String website = "javdb";
|
|
|
|
|
- List<VideoMonitorActors> videoMonitorActorsList = videoMonitorActorsMapper.findAllListByWebsite(website);
|
|
|
|
|
-
|
|
|
|
|
- /*forkJoinPool.submit(() -> videoMonitorActorsList.parallelStream().forEach(e -> {
|
|
|
|
|
- })).join();*/
|
|
|
|
|
-
|
|
|
|
|
- Document document;
|
|
|
|
|
- Elements itembSelects;
|
|
|
|
|
- for (VideoMonitorActors videoMonitorActors : videoMonitorActorsList) {
|
|
|
|
|
- try {
|
|
|
|
|
- List<String> insertCodeList = new ArrayList<>();
|
|
|
|
|
- List<String> codeList = videoMonitorActorsMapper.findAllLogListBySymbol(videoMonitorActors.getSymbol());
|
|
|
|
|
-
|
|
|
|
|
- Map<String, String> headerMap = new HashMap<>();
|
|
|
|
|
- headerMap.put("referer", videoMonitorActors.getHttpUrl());
|
|
|
|
|
- document = JsoupUtil.requestDocument(videoMonitorActors.getHttpUrl(), JsoupUtil.HTTP_GET, proxy, null, headerMap, null);
|
|
|
|
|
- itembSelects = document.select("div.movie-list").select("div.item");
|
|
|
|
|
-
|
|
|
|
|
- for (Element itembSelect : itembSelects) {
|
|
|
|
|
- String code = itembSelect.select("a.box").get(0).select("div.video-title").select("strong").text().trim().toUpperCase();
|
|
|
|
|
- if (codeList.contains(code)) {
|
|
|
|
|
- continue;
|
|
|
|
|
|
|
+ scheduler.scheduleAtFixedRate(() -> {
|
|
|
|
|
+ log.warn("monitorActors开始==============================");
|
|
|
|
|
+ beforeJavbus();
|
|
|
|
|
+
|
|
|
|
|
+ String website = "javdb";
|
|
|
|
|
+ List<VideoMonitorActors> videoMonitorActorsList = videoMonitorActorsMapper.findAllListByWebsite(website);
|
|
|
|
|
+
|
|
|
|
|
+ Document document;
|
|
|
|
|
+ Elements itembSelects;
|
|
|
|
|
+ for (VideoMonitorActors videoMonitorActors : videoMonitorActorsList) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ List<String> insertCodeList = new ArrayList<>();
|
|
|
|
|
+ List<String> codeList = videoMonitorActorsMapper.findAllLogListBySymbol(videoMonitorActors.getSymbol());
|
|
|
|
|
+
|
|
|
|
|
+ Map<String, String> headerMap = new HashMap<>();
|
|
|
|
|
+ headerMap.put("referer", videoMonitorActors.getHttpUrl());
|
|
|
|
|
+ document = JsoupUtil.requestDocument(videoMonitorActors.getHttpUrl(), JsoupUtil.HTTP_GET, proxy, null, headerMap, null);
|
|
|
|
|
+ itembSelects = document.select("div.movie-list").select("div.item");
|
|
|
|
|
+
|
|
|
|
|
+ for (Element itembSelect : itembSelects) {
|
|
|
|
|
+ String code = itembSelect.select("a.box").get(0).select("div.video-title").select("strong").text().trim().toUpperCase();
|
|
|
|
|
+ if (codeList.contains(code)) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ insertCodeList.add(code);
|
|
|
|
|
+
|
|
|
|
|
+ String url = itembSelect.select("a.box").get(0).attr("abs:href");
|
|
|
|
|
+ String title = itembSelect.select("a.box").get(0).attr("title");
|
|
|
|
|
+ String score = itembSelect.select("a.box").get(0).select("div.score").text().replace(" ", "").trim();
|
|
|
|
|
+ String date = itembSelect.select("a.box").get(0).select("div.meta").text().trim();
|
|
|
|
|
+ String tags = itembSelect.select("a.box").get(0).select("div.tags").text().trim();
|
|
|
|
|
+
|
|
|
|
|
+ String content = "<div class=\"highlight\">演员:" + videoMonitorActors.getActorsRemark() + "</div>" +
|
|
|
|
|
+ "<div>识别码:" + code + "</div>" +
|
|
|
|
|
+ "<div>标题:" + title + "</div>" +
|
|
|
|
|
+ "<div>发行日期:" + date + "</div>" +
|
|
|
|
|
+ "<div class=\"gray\">评价:" + score + "</div>" +
|
|
|
|
|
+ "<div class=\"gray\">标签:" + tags + "</div>";
|
|
|
|
|
+
|
|
|
|
|
+ JSONObject params = new JSONObject();
|
|
|
|
|
+ params.put("title", "JAVDB演员监控报警");
|
|
|
|
|
+ params.put("logUrl", url);
|
|
|
|
|
+ params.put("btnTxt", "影片详情");
|
|
|
|
|
+ monitorAlarm4APP_TEXT_CARD(content, params);
|
|
|
|
|
+
|
|
|
|
|
+ Thread.sleep(1000);
|
|
|
}
|
|
}
|
|
|
- insertCodeList.add(code);
|
|
|
|
|
-
|
|
|
|
|
- String url = itembSelect.select("a.box").get(0).attr("abs:href");
|
|
|
|
|
- String title = itembSelect.select("a.box").get(0).attr("title");
|
|
|
|
|
- String score = itembSelect.select("a.box").get(0).select("div.score").text().replace(" ", "").trim();
|
|
|
|
|
- String date = itembSelect.select("a.box").get(0).select("div.meta").text().trim();
|
|
|
|
|
- String tags = itembSelect.select("a.box").get(0).select("div.tags").text().trim();
|
|
|
|
|
-
|
|
|
|
|
- String content = "<div class=\"highlight\">演员:" + videoMonitorActors.getActorsRemark() + "</div>" +
|
|
|
|
|
- "<div>识别码:" + code + "</div>" +
|
|
|
|
|
- "<div>标题:" + title + "</div>" +
|
|
|
|
|
- "<div>发行日期:" + date + "</div>" +
|
|
|
|
|
- "<div class=\"gray\">评价:" + score + "</div>" +
|
|
|
|
|
- "<div class=\"gray\">标签:" + tags + "</div>";
|
|
|
|
|
-
|
|
|
|
|
- JSONObject params = new JSONObject();
|
|
|
|
|
- params.put("title", "JAVDB演员监控报警");
|
|
|
|
|
- params.put("logUrl", url);
|
|
|
|
|
- params.put("btnTxt", "影片详情");
|
|
|
|
|
- SpringUtils.getBean(Crawler4JavdbServiceImpl.class).monitorAlarm4APP_TEXT_CARD(content, params);
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
- videoMonitorActorsMapper.insertLogList(insertCodeList, videoMonitorActors.getSymbol());
|
|
|
|
|
- } catch (Exception e) {
|
|
|
|
|
- e.printStackTrace();
|
|
|
|
|
|
|
+ videoMonitorActorsMapper.insertLogList(insertCodeList, videoMonitorActors.getSymbol());
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
|
|
+ log.warn("monitorActors结束==============================");
|
|
|
|
|
+ }, 0, 2, TimeUnit.HOURS);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- @Async
|
|
|
|
|
public void monitorAlarm4APP_TEXT_CARD(String content, JSONObject params) {
|
|
public void monitorAlarm4APP_TEXT_CARD(String content, JSONObject params) {
|
|
|
// 文本卡片模式发消息
|
|
// 文本卡片模式发消息
|
|
|
String title = "监控告警明细";
|
|
String title = "监控告警明细";
|