簡體   English   中英

如何使用Jsoup選擇這些元素中的每一個?

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

我有此頁面,我想從中收集多個值:

在此處輸入圖片說明

我嘗試了多個不同的選擇器,但似乎無法使它們工作,並且它們什么也不返回,我發現這是:

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

獲取第一個“ f”值7,但我無法像這樣獲得塊中的其余行:

在此處輸入圖片說明

更新:我現在也嘗試將Phantomjs與WebDiver一起使用以選擇元素,並且它返回“ No Such Element Exception”(否此類元素異常)? 我使用的Xpath是:

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

為什么我無法選擇此內容?

嘗試選擇第一個period所有reps

然后遍歷Elements

Somethig喜歡:

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

希望對您有所幫助

PS:精美的藝術品:)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM