用jsoup找不到div元素

时间:2022-06-26 21:03:49

I want to extract the red marked Information from this website with jsoup.

我想用jsoup从这个网站中提取红色标记的信息。

用jsoup找不到div元素

The html text of this site is presented by the following picture. The Information i want to extract is red marked again.

本网站的html文本如下图所示。我要提取的信息再次被红色标记。

用jsoup找不到div元素

The Problem is that i can't find the div element with the class attribute "found-elements". My Code looks like this

问题是我找不到具有class属性“found-elements”的div元素。我的代码看起来像这样

public static void main(String[] args) {
    try {
        Document doc = Jsoup.connect("https://bestmentor.edudip.com/webinar/Lebe-deine-Berufung-und-deine-Arbeit-ist-Liebe/89620").get();           
        Elements ereignisse = doc.select("div#rating-entries div.found-elements article.rating div.text p");
        //Elements ereignisse = doc.select("body div#com-edudip-main-container div#content div.bottom div.academy-sidebar div.box div.ratings-exist div#rating-entries div.found-elements");        

        System.out.println(ereignisse.size());
        // Selektierte Elemente ausgeben ohne HTML-Tags
        for (Element e : ereignisse) {

            System.out.println(e.cssSelector());
            System.out.println(e.text());
        }
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}

It would be really kind if somebody could help me.

如果有人可以帮助我,那真是太好了。

Thank you.

1 个解决方案

#1


1  

Looks like you are targeting content that is loaded via ajax after the page load. Jsoup does not execute script, but as an alternative you could switch to using a headless web browser such as Phantomjs

看起来您的目标是在页面加载后通过ajax加载的内容。 Jsoup不执行脚本,但作为替代方案,您可以切换到使用无头Web浏览器,如Phantomjs

#1


1  

Looks like you are targeting content that is loaded via ajax after the page load. Jsoup does not execute script, but as an alternative you could switch to using a headless web browser such as Phantomjs

看起来您的目标是在页面加载后通过ajax加载的内容。 Jsoup不执行脚本,但作为替代方案,您可以切换到使用无头Web浏览器,如Phantomjs