13 jsoup解析字符串

时间:2023-1-17    作者:老大夫    分类: 传智JAVA爬虫学习笔记


测试类文件

 @Test
    public void testString()throws Exception{
        //使用工具类获取字符串
        String content = FileUtils.readFileToString(new File("C:\\Users\\16259\\Desktop\\test.html"), "utf8");

        //解析字符串
        Document doc = Jsoup.parse(content);

        String title = doc.getElementsByTag("title").first().text();
        System.out.println(title);
    }


扫描二维码,在手机上阅读

推荐阅读: