比较jsoup元素

compare jsoup elements

本文关键字:元素 jsoup 比较      更新时间:2023-09-26

你好,伙计们,我正在尝试将一个jsoup元素与所有其他元素进行比较,如果两个元素相等,我需要计数++;在这种情况下,我需要将链接1中的所有元素与链接2中的所有元素进行比较链接3链接4…

Document document1 = Jsoup.parse(webPage1);
Elements links1 = document1.select("example");
Document document2 = Jsoup.parse(webPage2);
Elements links2 = document2.select("example");
Document document3 = Jsoup.parse(webPage3);
Elements links3 = document3.select("example");
Document document4 = Jsoup.parse(webPage4);
Elements links4 = document4.select("example");

代码是什么。。。。在JSP中。。。。

Elements只是Element的列表,因此兼容看起来像:

   for (Element element : links1) {
            if(links2.contains(element)){
                count++;
            }
            //maybe do the same thing with links3 links4.
        }

如果您想在JSP中完成,这是另一个问题。