Kaynağa Gözat

add:增加jsoupLoveFoot4jpfoot单番号调试v1

tujidelv 1 yıl önce
ebeveyn
işleme
67be1f74f2

+ 5 - 0
src/main/java/top/lvzhiqiang/controller/CrawlerController.java

@@ -248,6 +248,11 @@ public class CrawlerController {
 
         if (4 == status || 1 == status || 2 == status) {
             crawler4LoveFootService.jsoupLoveFoot4CrawingFail(status, ignoreRetryCount, website, identificationCode);
+        } if (41 == status) {
+            if (StringUtils.isEmpty(identificationCode)) {
+                throw new ParameterException("identificationCode不能为空!");
+            }
+            crawler4LoveFootService.jsoupLoveFoot4CrawingFail2(status, ignoreRetryCount, website, identificationCode);
         } else if (status > 10) {
             if (status == 11) {
                 crawler4LoveFootService.jsoupLoveFoot4avnoashi(status, isDel, ignoreRetryCount);

+ 2 - 0
src/main/java/top/lvzhiqiang/service/Crawler4LoveFootService.java

@@ -13,4 +13,6 @@ public interface Crawler4LoveFootService {
     void jsoupLoveFoot4CrawingFail(Integer status, Integer ignoreRetryCount, String website, String identificationCode);
 
     void jsoupLoveFoot4jpfoot(Integer status, Integer isDel, Integer ignoreRetryCount) throws Exception;
+
+    void jsoupLoveFoot4CrawingFail2(Integer status, Integer ignoreRetryCount, String website, String identificationCode);
 }

+ 57 - 0
src/main/java/top/lvzhiqiang/service/impl/Crawler4LoveFootServiceImpl.java

@@ -195,6 +195,63 @@ public class Crawler4LoveFootServiceImpl implements Crawler4LoveFootService {
         log.warn("jjsoupLoveFoot4CrawingFail 结束:totalCount={},successCount={},time={}", loveFootList.size(), successCount, stopWatch.getTotalTimeSeconds());
     }
 
+    @Async
+    @Override
+    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
+    public void jsoupLoveFoot4CrawingFail2(Integer status, Integer ignoreRetryCount, String website, String identificationCode) {
+        log.warn("jsoupLoveFoot4CrawingFail2 开始");
+        StopWatch stopWatch = new StopWatch();
+        stopWatch.start();
+
+        // 获取待抓取码列表
+        List<CrawlerLoveFoot> loveFootList = crawlerLoveFootMapper.findByCodeAndType(identificationCode, null, null);
+
+        if (loveFootList.size() == 0) {
+            log.warn("loveFootList为空");
+            return;
+        }
+        log.warn("jsoupLoveFoot4CrawingFail2 loveFootList size={}", loveFootList.size());
+
+        List<DicCode> dicCodeList = dicCodeMapper.findAll();
+        // 获取常量MAP
+        javbusConstantMap = dicCodeList.stream()
+                .filter(x -> x.getType() != null && 1 == x.getType() && x.getEnv().contains(env))
+                .collect(Collectors.toMap(DicCode::getCodeKey, DicCode::getCodeValue, (key1, key2) -> key1));
+        javdbConstantMap = dicCodeList.stream()
+                .filter(x -> x.getType() != null && 2 == x.getType() && x.getEnv().contains(env))
+                .collect(Collectors.toMap(DicCode::getCodeKey, DicCode::getCodeValue, (key1, key2) -> key1));
+
+        // 获取javbus防屏蔽地址
+        if ("javbus".equals(website)) {
+            javbusUrlList = videoSitePoolMapper.findUrlByTypeAndDeleteFlag(1, 1);
+            if (javbusUrlList.size() == 0) {
+                log.warn("javbusUrlList为空");
+                return;
+            }
+        }
+
+        // 代理及TOKEN设置
+        beforeProxy();
+        // 解析原始站点
+
+        // 通过关键词获取识别码
+        CrawlerLoveFoot crawlerLoveFoot = loveFootList.get(0);
+        try {
+            String message = parseKeywordsToCode(crawlerLoveFoot, crawlerLoveFoot.getName(), "javdb");
+            if (StringUtils.isNotEmpty(message)) {
+                throw new Exception(message);
+            }
+
+            crawlerLoveFootMapper.insertOrUpdate4jpfoot(crawlerLoveFoot);
+        } catch (Exception e) {
+            log.error("jsoupLoveFoot4CrawingFail2 detail fail,sourceUrl={}", crawlerLoveFoot.getOrginJpfootUrl(), e);
+            crawlerLoveFoot.setFailureCause(e.getMessage());
+            crawlerLoveFootMapper.insertOrUpdate4jpfoot(crawlerLoveFoot);
+        }
+
+        log.warn("jsoupLoveFoot4CrawingFail2 结束:totalCount={},time={}", loveFootList.size(), stopWatch.getTotalTimeSeconds());
+    }
+
     @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
     public int jsoupLoveFoot4CrawingFailSub(List<CrawlerLoveFoot> loveFootList, String website) {
         int successCount = 0;

+ 1 - 0
src/main/resources/static/crawler.html

@@ -246,6 +246,7 @@
                 <option value="2">获取关键词失败</option>
                 <option value="1">获取关键词成功</option>
                 <option value="4">爬取失败</option>
+                <option value="41">爬取失败2</option>
                 <option value="11">从0开始avnoashi</option>
                 <option value="12">从0开始jpfoot</option>
             </select>