简体   繁体   English

如何使用Jsoup选择这些元素中的每一个?

[英]How do I select each of these Elements with Jsoup?

I have this page that I would like to collect multiple values from: 我有此页面,我想从中收集多个值:

在此处输入图片说明

I have tried multiple different slectors but I cant seem to get them to work and they return nothing, I have found that this: 我尝试了多个不同的选择器,但似乎无法使它们工作,并且它们什么也不返回,我发现这是:

Elements eles = docWeather.select("rep:eq(0)");
String temp = eles.attr("f");

gets the first "f" value of 7 but I cant get the rest of the lines in the block like this: 获取第一个“ f”值7,但我无法像这样获得块中的其余行:

在此处输入图片说明

UPDATE: I have also now tried using Phantomjs with WebDiver to select the elements and it returns a "No Such Element Exception"? 更新:我现在也尝试将Phantomjs与WebDiver一起使用以选择元素,并且它返回“ No Such Element Exception”(否此类元素异常)? The Xpath I used was: 我使用的Xpath是:

WebElement weatherData = driver.findElement(By.xpath("//*[@id='collapsible4']"));

Why am I unable to select this content? 为什么我无法选择此内容?

Try to select all the reps of the first period . 尝试选择第一个period所有reps

Then iterate over the Elements . 然后遍历Elements

Somethig like: Somethig喜欢:

Elements eles = docWeather.select("location:eq(0) rep");
for (Element ele: select){
    String temp = eles.attr("f");
    System.out.println(temp );        
}

I Hope it helps 希望对您有所帮助

PS: Nice artworks :) PS:精美的艺术品:)

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

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