|
@@ -2,6 +2,7 @@ package top.lvzhiqiang.service.impl;
|
|
|
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.jsoup.Connection;
|
|
import org.jsoup.Connection;
|
|
|
|
|
+import org.jsoup.HttpStatusException;
|
|
|
import org.jsoup.Jsoup;
|
|
import org.jsoup.Jsoup;
|
|
|
import org.jsoup.nodes.Document;
|
|
import org.jsoup.nodes.Document;
|
|
|
import org.jsoup.nodes.Element;
|
|
import org.jsoup.nodes.Element;
|
|
@@ -1164,7 +1165,15 @@ public class BgServiceImpl implements BgService {
|
|
|
sampleBoxHref = sampleBoxEle.attr("abs:href");
|
|
sampleBoxHref = sampleBoxEle.attr("abs:href");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- responseImg = Jsoup.connect(sampleBoxHref).method(Connection.Method.GET).ignoreContentType(true).timeout(50 * 1000).execute();
|
|
|
|
|
|
|
+ try {
|
|
|
|
|
+ responseImg = Jsoup.connect(sampleBoxHref).method(Connection.Method.GET).ignoreContentType(true).timeout(50 * 1000).execute();
|
|
|
|
|
+ } catch (HttpStatusException e) {
|
|
|
|
|
+ sampleBoxHref = sampleBoxEle.select("img").attr("src");
|
|
|
|
|
+ if (!sampleBoxHref.contains("http")) {
|
|
|
|
|
+ sampleBoxHref = sampleBoxEle.select("img").attr("abs:src");
|
|
|
|
|
+ }
|
|
|
|
|
+ responseImg = Jsoup.connect(sampleBoxHref).method(Connection.Method.GET).ignoreContentType(true).timeout(50 * 1000).execute();
|
|
|
|
|
+ }
|
|
|
String sampleBoxFileName = sampleBoxHref.substring(sampleBoxHref.lastIndexOf("/") + 1);
|
|
String sampleBoxFileName = sampleBoxHref.substring(sampleBoxHref.lastIndexOf("/") + 1);
|
|
|
saveFile2(responseImg.bodyStream(), qibingPath.concat(qibingImgGF), sampleBoxFileName);
|
|
saveFile2(responseImg.bodyStream(), qibingPath.concat(qibingImgGF), sampleBoxFileName);
|
|
|
}
|
|
}
|