de/backend/src/main/java/io/dataease/service/wizard/ReptileService.java
fit2cloudrd 5e32cd9dde
refactor: 首页修改 (#1651)
* refactor:首页修改

* refactor: 首页修改

Co-authored-by: wangjiahao <1522128093@qq.com>
2022-01-18 12:38:33 +08:00

51 lines
1.7 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package io.dataease.service.wizard;
import io.dataease.commons.utils.HttpClientUtil;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import org.springframework.stereotype.Service;
import java.util.*;
/**
* Author: wangjiahao
* Date: 2022/1/11
* Description:
*/
@Service
public class ReptileService {
String blogUrl = "https://blog.fit2cloud.com/?cat=321";
//获取最新的前几条数据
private static int infoCount=1;
public List lastActive() {
List result = new ArrayList();
try {
//爬取最新数据
Document doc = Jsoup.parse(HttpClientUtil.get(blogUrl, null));
Elements elementsContent = doc.getElementsByAttributeValue("rel", "bookmark");
Elements elementsTime = doc.getElementsByTag("time");
for(int i = 0;i<infoCount;i++){
Element info = elementsContent.get(i*3);
Map<String, String> infoMap = new HashMap();
infoMap.put("title",info.attr("title"));
infoMap.put("href",info.attr("href"));
infoMap.put("time",elementsTime.get(i).childNode(0).outerHtml());
result.add(infoMap);
}
} catch (Exception e) {
//ignore
Map<String, String> infoMap = new HashMap();
infoMap.put("title","支持移动端展示数据源新增对DB2的支持DataEase开源数据可视化分析平台v1.6.0发布");
infoMap.put("href","https://blog.fit2cloud.com/?p=3200");
infoMap.put("time","2022年1月10日");
result.add(infoMap);
}
return result;
}
}