我正在使用Jsoup从URL获取亚马逊项目数据,并且需要遍历文档中的item
标记,但我找不到标记。
可以找到示例网址here。我做错了什么?
答案 0 :(得分:0)
请在将来搜索和发布代码,我花了几秒钟为这个问题找到一套合适的答案。
来源:
http://jsoup.org/cookbook/input/load-document-from-url
Document doc = Jsoup.connect("http://example.com/").get();
Elements elements = doc.body().select("item");
for (Element element : elements) {
System.out.println(element.ownText());
}
答案 1 :(得分:0)
我(...)需要遍历文档中的项目标签,但我找不到标签。
没有标记Sub Differentiation()
Set RECsheet = ThisWorkbook.Sheets("Reconciliation")
Set OTLsheet = ThisWorkbook.Sheets("OTL")
Set CONsheet = ThisWorkbook.Sheets("Consolidation")
lrREC = RECsheet.Cells(Sheets("RECsheet").Rows.Count, "A").End(xlUp).Row
lrOTL = ORLsheet.Cells(Sheets("OTLsheet").Rows.Count, "D").End(xlUp).Row
lrCON = CONsheet.Cells(Sheets("CONsheet").Rows.Count, "A").End(xlUp).Row
For i = 2 To lrCON
foundTrue = False
For j = 17 To lrOTL
If Sheets("CONSheet").Cells(i, 1).Value = Sheets("OTLsheet").Cells(j, 4).Value Then
foundTrue = True
Exit For
End If
Next j
If Not foundTrue Then
Sheets("CONSheet").Rows(i).Copy Destination:= _
Sheets("Consolidation").Rows(lrREC+ 1)
lrREC = lrREC + 1
End If
Next i
'stop screen from updating to speed things up
Application.ScreenUpdating = True
End Sub
。相反,它是一个item
元素,div
类。
s-item-container
Document doc = Jsoup //
.connect("http://www.amazon.com/s/ref=nb_sb_ss_i_1_4?url=search-alias%3Daps&field-keywords=clash+royale&sprefix=clas%2Caps%2C288&rh=i%3Aaps%2Ck%3Aclash+royale") //
.get();
for (Element item : doc.select("div.s-item-container")) {
System.out.println("-----");
System.out.println("Title: " + item.select("a.s-access-detail-page").attr("title"));
System.out.println("Customer Reviews Count: " + item.select("a[href$=#customerReviews]").text());
// Extract other data...
}