我在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上刪除沃爾瑪頁面。使用JSOUP刪除重複的elementText值
我建立基於用戶參數的URL和建設使用
Document doc = Jsoup.parse(contentVar);
對於下一步我想打印所有的產品/價格DOM對象。我用下面的代碼:
String price = doc.getElementsByClass("camelPrice").text();
String title = doc.getElementsByClass("ListItemLink").text();
System.out.println("Product: " + title);
System.out.println("Price: "+ price);
這裏我使用的價格和產品說明標籤。但我的結果是:
Title/Product Name: C1, C2, ... C16 (c is camera title) Price: $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
此處價格因可能的quickview標記而被複制。有沒有辦法用任何JSOUP方法去除價格duplicacy
是的,它現在還不是非常有用的。感謝您的迴應:) – CodeMonkey 2013-06-04 14:51:52