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