我在 JAVA 中使用 JSOUP DOM 解析器在URL http://www.walmart.com/search/search-ng.do?tab_value=all&search_query=camera&search_constraint=0&Find=Find&ss=false&ic=16_32报废沃尔玛页面。
我正在基于用户参数构建 URL 并使用构建 DOM 对象
Document doc = Jsoup.parse(contentVar);
对于下一步,我想打印所有产品/价格。我使用了以下代码:
String price = doc.getElementsByClass("camelPrice").text();
String title = doc.getElementsByClass("ListItemLink").text();
System.out.println("Product: " + title);
System.out.println("Price: "+ price);
在这里,我使用价格和产品描述的标签。但是我的结果是:
标题/产品名称:C1, C2, ... C16(c 是相机标题) 价格:$ 279.95 $ 279.95 $ 479.00 $ 479.00 $ $ 60.00 $ 60.00 $ 99.00 $ 99.00 429.00 $ 429.00 $ 129.00 $ 129.00 $ 109.00 $ 109.00 $ 89.00 $ 89.00 $ 384.00 $ 384.00 $ $ 69.00 $ 69.00 279.00 $ 279.00 $ 129.00 $ 129.00 $ 55.20 - $ $ 69.00 55.20 - $ $ 69.00:74.00 $:74.00 $ $ 119.00 119.00
由于可能的快速查看标签,此处的价格重复。有没有办法使用任何 JSOUP 方法来消除价格的重复