diff --git a/src/main/java/com/yomahub/githubhost/controller/HostsController.java b/src/main/java/com/yomahub/githubhost/controller/HostsController.java index 217e66c84bef11b9a0f9a65ade7cb07cb339fa93..00948a11bbd0fc6ce74f7ec4893a692a5dbb0feb 100644 --- a/src/main/java/com/yomahub/githubhost/controller/HostsController.java +++ b/src/main/java/com/yomahub/githubhost/controller/HostsController.java @@ -20,6 +20,7 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; +import org.springframework.util.StringUtils; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; @@ -118,18 +119,20 @@ public class HostsController { requestUrl = StrUtil.format("http://{}.{}/{}",domainName,ipAddressUrl,host); } - Connection.Response response = null; + String content; try { - response = Jsoup.connect(requestUrl).execute(); - } catch (IOException e) { + content = Jsoup.connect(requestUrl).execute().body(); + } catch (Exception e) { + return null; + } + + if (StringUtils.isEmpty(content)) { return null; } - String content = response.body(); - Document doc = Jsoup.parse(content); Elements elements; try{ - elements = doc.select("table[class=panel-item table table-stripes table-v]").get(0) + elements = Jsoup.parse(content).select("table[class=panel-item table table-stripes table-v]").get(0) .select("tr").last().select("td ul li"); }catch (Exception e){ return null;