【发布时间】:2015-07-07 13:54:02
【问题描述】:
我正在编写一个网络爬虫,使用 JSoup 从亚马逊搜索结果的第一页获取价格。例如,您在亚马逊上搜索“锤子”,搜索结果的第一页出现,我的爬虫获取每个搜索结果的所有价格并显示它们。但是,我无法弄清楚为什么在运行程序时没有打印任何内容。 Amazon.ca 上商品价格图的 HTML 是:
<a class="a-link-normal a-text-normal" href="http://www.amazon.ca/Stanley-51-624-Fiberglass-Hammer-20-Ounce/dp/B000VSSG2K/ref=sr_1_1?ie=UTF8&qid=1436274467&sr=8-1&keywords=hammer"><span class="a-size-base a-color-price s-price a-text-bold">CDN$ 17.52</span></a>
我的代码如下运行:
Elements prices = doc.getElementsByClass("a-size-base a-color-price s-price a-text-bold");
System.out.println("Prices: " + prices);
返回什么:
Prices:
在这种情况下如何获得价格值“CDN$ 17.52”?
【问题讨论】:
标签: java class get jsoup amazon