工会网站新闻
This commit is contained in:
@@ -310,28 +310,28 @@ public class SysHomeController {
|
||||
return Result.success(news);
|
||||
}
|
||||
SSLContextTrustAnyHostname.trustAllHosts();
|
||||
String url = "https://gh.hmc.edu.cn/";
|
||||
String url = "https://gh.zjitc.net/";
|
||||
Document document = null;
|
||||
document = Jsoup.connect(url).get();
|
||||
// 通知公告
|
||||
Elements notice = document.select("div.center_left");
|
||||
// 新闻快讯
|
||||
Elements newsFlash = document.select("td[valign=top][style=padding-left:10px; padding-right:10px;]");
|
||||
Elements notice = document.select("div.pull-left.index-notice.ml15");
|
||||
// 工会要闻
|
||||
Elements newsFlash = document.select("div.pull-left.dx");
|
||||
// 服务之窗
|
||||
Elements windowServer = document.select("div.center_center");
|
||||
//Elements windowServer = document.select("div.center_center");
|
||||
|
||||
// 通知公告
|
||||
List<Map<String, Object>> noticeList = notice.stream().map(homeElement -> {
|
||||
//获取板块名称
|
||||
String name = homeElement.selectFirst("td.lanmuname").text();
|
||||
String name = homeElement.selectFirst("div.section-title.scys").text();
|
||||
if (name.equals("通知公告")) {
|
||||
Elements liElements = homeElement.select("table[width=100%][border=0][cellspacing=0][cellpadding=0][style=margin-bottom:10px;]");
|
||||
Elements liElements = homeElement.select("li.flex-box");
|
||||
List<NutMap> notices = liElements.stream().map(liElement -> {
|
||||
NutMap row = NutMap.NEW();
|
||||
String href = liElement.selectFirst("a.list").attr("href");
|
||||
String time1 = liElement.selectFirst("div.riqinian").text();
|
||||
String time2 = liElement.selectFirst("div.riqiri").text();
|
||||
String title = liElement.selectFirst("a.list").text();
|
||||
String href = liElement.selectFirst("a.cal-title").attr("href");
|
||||
String time1 = liElement.selectFirst("div.cal-date-day").text();
|
||||
String time2 = liElement.selectFirst("div.cal-date-month").text();
|
||||
String title = liElement.selectFirst("a.cal-title").text();
|
||||
row.put("href", href);
|
||||
row.put("time", time1 + "-" + time2);
|
||||
row.put("text", title);
|
||||
@@ -342,18 +342,18 @@ public class SysHomeController {
|
||||
return null;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
// 新闻快讯
|
||||
// 工会要闻
|
||||
List<Map<String, Object>> newsFlashList = newsFlash.stream().map(homeElement -> {
|
||||
//获取板块名称
|
||||
String name = homeElement.selectFirst("td.lanmuname").text();
|
||||
if (name.equals("新闻快讯")) {
|
||||
Elements liElements = homeElement.select("td[valign=top][style=padding:10px;15px;10px;0px;]")
|
||||
.select("table[width=100%][border=0][cellspacing=0][cellpadding=0]");
|
||||
String name = homeElement.selectFirst("div.section-title.scys").text();
|
||||
if (name.equals("工会要闻")) {
|
||||
Elements liElements = homeElement.select("li.scli");
|
||||
|
||||
List<NutMap> notices = liElements.stream().map(liElement -> {
|
||||
NutMap row = NutMap.NEW();
|
||||
String href = liElement.selectFirst("a.list").attr("href");
|
||||
String time = liElement.selectFirst("td.list").text();
|
||||
String title = liElement.selectFirst("a.list").text();
|
||||
String href = liElement.selectFirst("a.flex-box").attr("href");
|
||||
String time = liElement.selectFirst("div.date-line").text();
|
||||
String title = liElement.selectFirst("div.flex-1").text();
|
||||
row.put("href", href);
|
||||
row.put("time", time);
|
||||
row.put("text", title);
|
||||
@@ -364,32 +364,32 @@ public class SysHomeController {
|
||||
return null;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
// 服务之窗
|
||||
List<Map<String, Object>> windowServerList = windowServer.stream().map(homeElement -> {
|
||||
//获取板块名称
|
||||
String name = homeElement.selectFirst("td.lanmuname").text();
|
||||
if (name.equals("服务之窗")) {
|
||||
Elements liElements = homeElement.select("table[width=100%][border=0][cellspacing=0][cellpadding=0][style=margin-bottom:8px;]");
|
||||
List<NutMap> notices = liElements.stream().map(liElement -> {
|
||||
NutMap row = NutMap.NEW();
|
||||
String href = liElement.selectFirst("a.list").attr("href");
|
||||
String time = liElement.selectFirst("td[height=15][width=40]").text().replaceAll("\\.", "-");
|
||||
String title = liElement.selectFirst("a.list").text();
|
||||
row.put("href", href);
|
||||
row.put("time", time);
|
||||
row.put("text", title);
|
||||
return row;
|
||||
}).collect(Collectors.toList());
|
||||
return Map.of("label", name, "value", notices);
|
||||
}
|
||||
return null;
|
||||
}).collect(Collectors.toList());
|
||||
// // 服务之窗
|
||||
// List<Map<String, Object>> windowServerList = windowServer.stream().map(homeElement -> {
|
||||
// //获取板块名称
|
||||
// String name = homeElement.selectFirst("td.lanmuname").text();
|
||||
// if (name.equals("服务之窗")) {
|
||||
// Elements liElements = homeElement.select("table[width=100%][border=0][cellspacing=0][cellpadding=0][style=margin-bottom:8px;]");
|
||||
// List<NutMap> notices = liElements.stream().map(liElement -> {
|
||||
// NutMap row = NutMap.NEW();
|
||||
// String href = liElement.selectFirst("a.list").attr("href");
|
||||
// String time = liElement.selectFirst("td[height=15][width=40]").text().replaceAll("\\.", "-");
|
||||
// String title = liElement.selectFirst("a.list").text();
|
||||
// row.put("href", href);
|
||||
// row.put("time", time);
|
||||
// row.put("text", title);
|
||||
// return row;
|
||||
// }).collect(Collectors.toList());
|
||||
// return Map.of("label", name, "value", notices);
|
||||
// }
|
||||
// return null;
|
||||
// }).collect(Collectors.toList());
|
||||
if (Lang.isNotEmpty(newsFlashList)) {
|
||||
noticeList.addAll(newsFlashList);
|
||||
}
|
||||
if (Lang.isNotEmpty(windowServerList)) {
|
||||
noticeList.addAll(windowServerList);
|
||||
}
|
||||
// if (Lang.isNotEmpty(windowServerList)) {
|
||||
// noticeList.addAll(windowServerList);
|
||||
// }
|
||||
redisService.setex("gonghui_news", 60 * 60 * 24, Json.toJson(noticeList));
|
||||
return Result.success(noticeList);
|
||||
} catch (IOException e) {
|
||||
|
||||
Reference in New Issue
Block a user