feat():爬取新闻中的图片文件

图片下载工具
master
Saisai 2024-08-30 10:00:08 +08:00
parent 4b631bcd1e
commit bb794dd37a
1 changed files with 4 additions and 0 deletions

View File

@ -31,7 +31,9 @@ public class ImageDownloaderUtil {
try { try {
httpResponse = httpClient.execute(httpGet); httpResponse = httpClient.execute(httpGet);
} catch (IOException e) { } catch (IOException e) {
logger.warn("execute http request fail:", e); logger.warn("execute http request fail:", e);
return;
} }
//非常简单的下载方法 //非常简单的下载方法
try { try {
@ -39,12 +41,14 @@ public class ImageDownloaderUtil {
httpResponse.getEntity().writeTo(out); httpResponse.getEntity().writeTo(out);
} catch (Exception e) { } catch (Exception e) {
logger.warn("save file fail:", e); logger.warn("save file fail:", e);
return;
} }
try { try {
//消耗实体 //消耗实体
EntityUtils.consume(httpResponse.getEntity()); EntityUtils.consume(httpResponse.getEntity());
} catch (IOException e) { } catch (IOException e) {
logger.warn("consume entity fail:", e); logger.warn("consume entity fail:", e);
return;
} }
} }
} }