繁体   English   中英

如何在jsoup中找到带有pseudoElement ::before的HTML标签

[英]How can I find a HTML tag with the pseudoElement ::before in jsoup

我将使用 jsoup 读取来自网站的 img 链接。 当我搜索 HTML 代码时,我在 ::before ( https://developer.mozilla.org/en-US/docs/Web/CSS/::before ) 元素中找到了链接,例如

::before 
<span>
<img src="https://link.png" alt=""> 
</span>

我的Java代码:

import java.io.IOException;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;

public class JavaApplication6 {

    public static void main(String[] args) throws IOException {

            String link = "https://www.panasonic.com/de/consumer/foto-video/lumix-kompaktkameras/dmc-lx100.html";

            Document docHauptseite = Jsoup.connect(link)
                    .userAgent("Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.1")
                    .referrer("http://www.google.com")
                    .followRedirects(true)
                    .get();


            Elements sImages = docHauptseite.getElementsByClass("thumb-block");
            System.out.println("sImages count = " + sImages.size());

            Elements sImagesFeatures = docHauptseite.getElementsByClass("featureslide650image");
            System.out.println("sImagesFeatures count = " + sImagesFeatures.size());



    }
}

我在 class="thumb-block" 中没有得到任何结果。 如果我查看 HTML 代码,我可以看到:

<div class="thumb-block">
::before
    <span>
        <img src="https:link" alt="DMC-LX100 Premium-Kompaktkamera Bild für Miniaturansicht 2">
    </span>
</div>

在 jsoup 结果中,我没有以 ::before 元素开头的标签。 有谁知道,我如何用jsoup解决这个问题?

非常感谢

好的。 我阅读了更多信息。

内容通过 JavaScript 添加到 html 代码中。 Jsoup 不支持 JavaScript。 所以 Jsoup 是不可能的。

我将尝试使用其他工具(如 Selenium)。

谢谢你。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM