Jsoup 筆記

public static String getStdoutLog(Document document,String host){
List<Element> list = document.select("td.content > p > a[href]");
if(list.size()>1){
for (Element e:list){
String stdouturl = e.attr("href");
if(stdouturl.contains(InsightConstants.CDH_LOG_STDOUT)){
String stdouturls = "http://" + host + ":19888" + stdouturl;
Document logcontent = null;

try {
logcontent = Jsoup.connect(stdouturls).get();
} catch (IOException e1) {
e1.printStackTrace();
}

return logcontent !=null?logcontent.select("td.content > pre").text() :"";
}
}
}else{
List<Element> lists = document.select("td.content > pre");
for (Element element:lists){
if(element.text().contains("===DataExa-Insight Action Invoker Started===")){
return element.text();
}
}
}
return "";
}
public static String getStderrLog(Document document, String host) {    List<Element> list = document.select("td.content > p > a[href]");    if(list.size()>1){        Document logcontent;        for(Element element:list){            String stderrurl = element.attr("href");            if(stderrurl.contains(InsightConstants.CDH_LOG_STDERR)){                String stderrurls = "http://" + host + ":19888" + stderrurl;                try {                    logcontent = Jsoup.connect(stderrurls).get();                } catch (IOException e) {                    e.printStackTrace();                    return "";                }                return logcontent !=null?logcontent.select("td.content > pre").text() :"";            }        }    }else{        List<Element> lists = document.select("td.content > pre");        return lists.get(0).text();    }    return "";}
相關文章
相關標籤/搜索