|
|
@@ -379,7 +379,7 @@ public class PictureInfoServiceImpl extends BaseServiceImpl<Object> implements P
|
|
|
failCount++;
|
|
|
} finally {
|
|
|
pictureInfoMapper.insertOrUpdateFileCrawlerImageLog(fileCrawlerImageLog);
|
|
|
- log.warn("jsoupFulibaPicDetail update status:mainUrl={},status={}", mainUrl, fileCrawlerImageLog.getStatus());
|
|
|
+ log.warn("jsoupFulibaPicDetail update status:mainUrl={},status={}", fileCrawlerImageLog.getMainUrl(), fileCrawlerImageLog.getStatus());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -413,12 +413,16 @@ public class PictureInfoServiceImpl extends BaseServiceImpl<Object> implements P
|
|
|
newName = newName + prefx;
|
|
|
|
|
|
Connection.Response response = Jsoup.connect(srcUrl).method(Connection.Method.GET).ignoreContentType(true).timeout(50 * 1000).execute();
|
|
|
+ byte[] imageBytes = response.bodyAsBytes();
|
|
|
+ if (imageBytes.length == 0) {
|
|
|
+ // 过滤掉失效的图片链接
|
|
|
+ continue;
|
|
|
+ }
|
|
|
|
|
|
FileCrawlerImage fileCrawlerImage = new FileCrawlerImage();
|
|
|
fileCrawlerImage.setOldName(altTitle);
|
|
|
fileCrawlerImage.setNewName(newName);
|
|
|
|
|
|
- byte[] imageBytes = response.bodyAsBytes();
|
|
|
imageSize = BigDecimal.valueOf(imageBytes.length).divide(new BigDecimal("1024")).setScale(0, RoundingMode.UP).toPlainString().concat("KB");
|
|
|
fileCrawlerImage.setSize(imageSize);
|
|
|
|
|
|
@@ -442,6 +446,9 @@ public class PictureInfoServiceImpl extends BaseServiceImpl<Object> implements P
|
|
|
ByteArrayInputStream thumbnailInputStream = new ByteArrayInputStream(thumbnailOutputStream.toByteArray());
|
|
|
FtpUtil.uploadFile(ftpThumbnailCrawlerBasePath, parentPath, newName, thumbnailInputStream);
|
|
|
delPathList.add(ftpThumbnailCrawlerBasePath + imageUrl);
|
|
|
+
|
|
|
+ imageStream2.close();
|
|
|
+ thumbnailOutputStream.close();
|
|
|
}
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
@@ -455,4 +462,11 @@ public class PictureInfoServiceImpl extends BaseServiceImpl<Object> implements P
|
|
|
}
|
|
|
return "";
|
|
|
}
|
|
|
+
|
|
|
+ public static void main(String[] args) throws IOException {
|
|
|
+ String srcUrl = "https://image.baidu.com/search/down?thumburl=https://baidu.com&url=https://tva1.sinaimg.cn/mw690/007Y7SRMly1gmays3w173j30ol16fh8x.jpg";
|
|
|
+ Connection.Response response = Jsoup.connect(srcUrl).method(Connection.Method.GET).ignoreContentType(true).timeout(50 * 1000).execute();
|
|
|
+ byte[] imageBytes = response.bodyAsBytes();
|
|
|
+ System.out.println(imageBytes.length);
|
|
|
+ }
|
|
|
}
|