如何在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.
谢谢.