Elements media = document.select("[src]");
Elements imports = document.select("link[href]");
Elements pages = document.select("a[href]");
logOutputFormat("\nTotal Media: (%d)", media.size());
DownloadContent downloadContent = null;
for (Element src : media) {
downloadContent = downloadFile(src.absUrl("src"), ContentType.MEDIA);
if(null != downloadContent) {
if (src.tagName().equals("img")) {
logOutputFormat(" * %s: <%s> %sx%s (%s) , %.3f%n", src.tagName(), src.attr("abs:src"), src.attr("width"), src.attr("height"), trim(src.attr("alt"), 20), downloadContent.getTime());
} else {
logOutputFormat(" * %s: <%s> , %.3f%n ", src.tagName(), src.attr("abs:src"), downloadContent.getTime());
}
} else {
logOutputFormat("%s: <%s>", "There is a problem downloading file : ", src.attr("abs:src"));
downloadContent = new DownloadContent();
downloadContent.setErrorMsg("Cannot download file from this URL");
}
downloadLst.add(downloadContent);
}
logOutputFormat("\nTotal Imports: (%d)", imports.size());
for (Element link : imports) {
downloadContent = downloadFile(link.attr("abs:href"), ContentType.IMPORT);
if(null != downloadContent) {
logOutputFormat(" * %s <%s> (%s)", link.tagName(), link.attr("abs:href"), link.attr("rel"));
} else {
logOutputFormat("%s: <%s>", "There is a problem downloading file : ", link.attr("abs:href"));
downloadContent = new DownloadContent();
downloadContent.setErrorMsg("Cannot download file from this URL");
}
downloadLst.add(downloadContent);
}
logOutputFormat("\nTotal Pages: (%d)", pages.size());
for (Element page : pages) {
//response = getConnectionResponse(link.attr("abs:href"));
downloadContent = downloadFile(page.attr("abs:href"), ContentType.PAGE);
if(null != downloadContent ){
logOutputFormat(" * a: <%s> (%s)", page.attr("abs:href"), trim(page.text(), 35));
} else {
downloadContent = new DownloadContent();
downloadContent.setTime(-1.00);
downloadContent.setErrorMsg("Cannot download file from this URL");
}
downloadLst.add(downloadContent);
}
return downloadLst;
}