lvzhiqiang 3 vuotta sitten
vanhempi
commit
af9a3f727d

+ 10 - 0
src/main/java/top/lvzhiqiang/mapper/CrawlerJavbusProfileMapper.java

@@ -3,6 +3,7 @@ package top.lvzhiqiang.mapper;
 import org.apache.ibatis.annotations.Delete;
 import org.apache.ibatis.annotations.Insert;
 import org.apache.ibatis.annotations.Select;
+import org.apache.ibatis.annotations.Update;
 import top.lvzhiqiang.entity.CrawlerJavbusLog;
 import top.lvzhiqiang.entity.CrawlerJavbusProfile;
 
@@ -93,4 +94,13 @@ public interface CrawlerJavbusProfileMapper {
      */
     @Select("SELECT * FROM crawler_javbus_log WHERE delete_flag = 1 and status = #{status}")
     List<CrawlerJavbusLog> findJavbusLogByStatus(Integer status);
+
+    /**
+     * 根据id删除
+     */
+    @Update("update crawler_javbus_log set delete_flag = 2, modify_time = now() where id = #{id}")
+    void deleteJavbusLogById(Long id);
+
+    @Update("update crawler_javbus_log set delete_flag = 2, error_msg=#{errorMsg}, modify_time = now() where id = #{id}")
+    void deleteJavbusLogById(Long id, String errorMsg);
 }

+ 10 - 0
src/main/java/top/lvzhiqiang/service/impl/Crawler4JavbusServiceImpl.java

@@ -191,6 +191,16 @@ public class Crawler4JavbusServiceImpl implements Crawler4JavbusService {
                 profileDocument = JsoupUtil.requestDocument(profileUrl.concat(javbusLog.getBusinessKey()), JsoupUtil.HTTP_GET, proxy, javbusCookiesMap, null, null);
                 if (profileDocument.html().contains("您指定的用戶空間不存在")) {
                     log.warn("jsoupJavbusProfileSub您指定的用戶空間不存在,start={}", javbusLog.getBusinessKey());
+
+                    crawlerJavbusProfileMapper.deleteJavbusLogById(javbusLog.getId());
+
+                    continue;
+                }
+                if (profileDocument.html().contains("空間已被鎖定無法訪問")) {
+                    log.warn("jsoupJavbusProfileSub空間已被鎖定無法訪問,start={}", javbusLog.getBusinessKey());
+
+                    crawlerJavbusProfileMapper.deleteJavbusLogById(javbusLog.getId(), "空間已被鎖定無法訪問,如有疑問請聯繫管理員");
+
                     continue;
                 }