RainngCourse icon indicating copy to clipboard operation
RainngCourse copied to clipboard

[Discussion] SdnuNewsManager content about RainngCourseBE module

Open dyingChinese opened this issue 1 year ago • 0 comments



@Component
public class SdnuNewsManager extends BaseManager {
    private static final int CRAWL_INTERVAL = 60 * 60 * 1000;
    private static final int CRAWL_TIMEOUT = 30 * 1000;
    private static final String CRAWL_TARGET_URL = "http://www.bkjy.sdnu.edu.cn/xszq1.htm";

    private static final String BASE_URL = "http://www.bkjy.sdnu.edu.cn/";

    private final SdnuNewsDAO sdnuNewsDAO;

    public SdnuNewsManager(SdnuNewsDAO sdnuNewsDAO) {
        this.sdnuNewsDAO = sdnuNewsDAO;
    }

    public List<SdnuNewsBO> getAllNews() {
        Map<String, String> map = sdnuNewsDAO.getAllNews();

        List<SdnuNewsBO> newsList = new ArrayList<>(map.size());
        for (String key : map.keySet()) {
            String value = map.get(key);
            // 2019/01/01http://host/path
            String date = value.substring(0, 10);
            String url = value.substring(10);
            newsList.add(new SdnuNewsBO(key, date, url));
        }

        return newsList;
    }

    @Scheduled(fixedDelay = CRAWL_INTERVAL)
    public void crawlNews() {
        Document pageDoc = fetchPage();
        if (pageDoc == null) {
            return;
        }

        List<SdnuNewsBO> newsList = parseNews(pageDoc);
        sdnuNewsDAO.clear();
        for (SdnuNewsBO news : newsList) {
            sdnuNewsDAO.addNews(news.getTitle(), news.getDate() + news.getUrl());
        }
    }

    private Document fetchPage() {
        Document doc = null;
        try {
            doc = Jsoup.parse(new URL(CRAWL_TARGET_URL), CRAWL_TIMEOUT);
        } catch (IOException ex) {
            ex.printStackTrace();
        }

        return doc;
    }

I discovered that this class attempts to crawl a specified web page, but the content of this web page no longer exists.

Should I continue to use this class?

Perhaps I should simply use the return value as null.

These are the links I can obtain from the specified page. I cannot find anything related to xszq1.htm, or any tags with TB3/Table in the code content.

NO title URL
1 山東師範大學教務處 http://www.bkjy.sdnu.edu.cn
2 山東師範大學教務處 http://www.bkjy.sdnu.edu.cn/index.htm
3 通知公告-山東師範大學教務處 http://www.bkjy.sdnu.edu.cn/index/tzgg.htm
4 新聞動態-山東師範大學教務處 http://www.bkjy.sdnu.edu.cn/index/xwdt.htm
5 學院動態-山東師範大學教務處 http://www.bkjy.sdnu.edu.cn/index/xydt.htm
6 現任領導-山東師範大學教務處 http://www.bkjy.sdnu.edu.cn/bmgk/xrld.htm
7 部門設置-山東師範大學教務處 http://www.bkjy.sdnu.edu.cn/bmgk/bmsz.htm
8 聯繫方式-山東師範大學教務處 http://www.bkjy.sdnu.edu.cn/bmgk/lxfs.htm
9 工作職責-山東師範大學教務處 http://www.bkjy.sdnu.edu.cn/bmgk/gzzz.htm
10 專業建設-山東師範大學教務處 http://www.bkjy.sdnu.edu.cn/rcpy/zyjs.htm
11 培養方案-山東師範大學教務處 http://www.bkjy.sdnu.edu.cn/rcpy/pyfa.htm
12 課程建設-山東師範大學教務處 http://www.bkjy.sdnu.edu.cn/rcpy/kcjs.htm
13 教材建設-山東師範大學教務處 http://www.bkjy.sdnu.edu.cn/rcpy/jcjs.htm
14 师範教育-山東師範大學教務處 http://www.bkjy.sdnu.edu.cn/rcpy/sfjy.htm
15 學籍管理-山東師範大學教務處 http://www.bkjy.sdnu.edu.cn/jxgl/xjgl.htm
16 教學運行-山東師範大學教務處 http://www.bkjy.sdnu.edu.cn/jxgl/jxyx.htm
17 實踐教學-山東師範大學教務處 http://www.bkjy.sdnu.edu.cn/jxgl/sjjx.htm
18 實驗中心-山東師範大學教務處 http://www.bkjy.sdnu.edu.cn/jxgl/syzx.htm
19 大學生競賽-山東師範大學教務處 http://www.bkjy.sdnu.edu.cn/jxgl/dxsjs.htm
20 办事指南-山东师范大学教务处 http://www.bkjy.sdnu.edu.cn/ssfw/bszn.htm

dyingChinese avatar Jun 21 '24 07:06 dyingChinese