Jsoup --获取页面表格数据

可以使用json,根据页面结构获取页面表格的指定内容

依赖

    <dependency>
        <groupId>org.jsoup</groupId>
        <artifactId>jsoup</artifactId>
        <version>1.14.1</version>
    </dependency>

获取指定页面的表格(使用getElementById)

     /**
      * @Description: 获取人员列表element
      * @param cookiefro cookie 前缀 ,personUrl 人员列表地址 cookie
      * @return ${return_type}
      * @throws
      * @author 康世行
      * @date 2021-10-10 23:35
      */
    private Element classManageTable(String cookieFro, String personUrl, String cookie){

        String personNameListHtml = HttpUtils.sendHttHtml(cookieFro+cookie, personUrl);
        Document parse = Jsoup.parse(personNameListHtml);//转换为Document
        Element classManageTable = parse.getElementById("classManageTable");//获取表格
        return classManageTable;
    }
posted @ 2021-10-12 17:33  康世行  阅读(180)  评论(0编辑  收藏  举报