【发布时间】:2016-01-15 13:59:21
【问题描述】:
我有这个html代码,我需要获取链接
<div class="squaresContent narrow">
<input type="hidden" id="category_path" value="1_Komputery > Części i obudowy komputerowe > Dyski twarde" />
<div class="productItem first2Col first3Col first4Col first">
<a class="productItemContent withNames productsView" href='http://www.okazje.info.pl/km/komputery/samsung-ssd-850-evo-250gb-sata3-2-5-mz-75e250b-eu.html'>
接下来我做:
String ref = null;
for (Element el : doc.getElementsByClass("squaresContent narrow")) {
for (Element elem : el.getElementsByClass("productItem first2Col first3Col first4Col first")
.select("a")) {
ref = elem.attr("abs:href");
}
}
但它不起作用。
我该怎么办?
【问题讨论】:
-
你试过调试吗?
标签: java html-parsing jsoup