如何在jsoup中使用伪元素:: before找到HTML标记 [英] How can I find a HTML tag with the pseudoElement ::before in jsoup

查看:514
本文介绍了如何在jsoup中使用伪元素:: before找到HTML标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将使用jsoup阅读网站上的img链接.当我搜索HTML代码时,我在:: before中找到链接 ( https://developer.mozilla.org/zh-CN /docs/Web/CSS/:: before )元素

I will read the img links from a website with jsoup. When I search the HTML code I find the links in a ::before (https://developer.mozilla.org/en-US/docs/Web/CSS/::before) element like

::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代码,我会看到:

I got no results in the class="thumb-block". If I look at the HTML code i can see:

<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解决这个问题?

In the jsoup result I got no tags which starts with the ::before element. Has anyone an idea, how I can fix this with jsoup?

非常感谢您

推荐答案

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

Okay. I read some more informations.

内容通过JavaScript添加到html代码中. Jsoup不支持JavaScript.因此,使用Jsoup是不可能的.

The content is added to the html-code by JavaScript. Jsoup don't support JavaScript. So it is not possible with Jsoup.

我将与Selenium等其他工具一起尝试.

I will try it with an other tool like Selenium.

谢谢.

这篇关于如何在jsoup中使用伪元素:: before找到HTML标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆