commit
This commit is contained in:
@@ -270,65 +270,24 @@ public class SysHomeController {
|
||||
Document doc = Jsoup.connect(domain).get();
|
||||
|
||||
JSONObject root = new JSONObject();
|
||||
/*
|
||||
// 1. 新闻快讯(来自 .list1)
|
||||
List<JSONObject> newsArray = new ArrayList<>();
|
||||
Elements newsItems = doc.select(".group1 .list1 li");
|
||||
Elements newsItems = doc.select("table[cellspacing=3] tr");
|
||||
for (Element item : newsItems) {
|
||||
String date = item.select(".date").text().trim();
|
||||
Element link = item.select("a.text").first();
|
||||
String title = link.select(".title").text().trim();
|
||||
String url = link.attr("href").trim();
|
||||
Element aElement = item.select("a").first();
|
||||
if(aElement == null) {
|
||||
continue;
|
||||
}
|
||||
String date = item.select(".timestyle125262").text().trim();
|
||||
String title = aElement.attr("title").trim();
|
||||
String url = aElement.attr("href").trim();
|
||||
|
||||
JSONObject node = new JSONObject();
|
||||
node.set("title", title);
|
||||
node.set("date", date);
|
||||
node.set("url", domain + url);
|
||||
node.set("url", "https://gh.hgu.edu.cn/" + url);
|
||||
newsArray.add(node);
|
||||
}
|
||||
root.set("news", newsArray);
|
||||
|
||||
// 2. 通知公告(来自 .list2)
|
||||
List<JSONObject> noticesArray = new ArrayList<>();
|
||||
Elements noticeItems = doc.select(".group2 .list2 li");
|
||||
for (Element item : noticeItems) {
|
||||
String date = item.select(".date").text().trim();
|
||||
Element link = item.select("a.title").first();
|
||||
String title = link.text().trim();
|
||||
String url = link.attr("href").trim();
|
||||
JSONObject node = new JSONObject();
|
||||
node.set("title", title);
|
||||
node.set("date", date);
|
||||
node.set("url", domain + url);
|
||||
noticesArray.add(node);
|
||||
}
|
||||
root.set("notices", noticesArray);
|
||||
|
||||
// 3. 基层风采(来自 .pic-list1)
|
||||
List<JSONObject> grassrootsArray = new ArrayList<>();
|
||||
Elements grassrootsItems = doc.select(".group3 .pic-list1 li");
|
||||
for (Element item : grassrootsItems) {
|
||||
Element link = item.select("a.img-scale").first();
|
||||
String date = link.select(".date").text().trim();
|
||||
String title = link.select(".title").text().trim();
|
||||
String url = link.attr("href").trim();
|
||||
String summary = link.select(".info").text().trim();
|
||||
|
||||
String imageUrl = "";
|
||||
Element img = link.select("img").first();
|
||||
if (img != null) {
|
||||
imageUrl = img.attr("src").trim();
|
||||
}
|
||||
|
||||
JSONObject node = new JSONObject();
|
||||
node.set("title", title);
|
||||
node.set("date", date);
|
||||
node.set("url", domain + url);
|
||||
node.set("summary", summary);
|
||||
node.set("image", domain + imageUrl);
|
||||
grassrootsArray.add(node);
|
||||
}
|
||||
root.set("grassroots", grassrootsArray);*/
|
||||
root.set("grassroots", newsArray);
|
||||
return Result.success(root);
|
||||
} catch (Exception e) {
|
||||
log.error(e);
|
||||
|
||||
Reference in New Issue
Block a user