跨度返回空空白
问题描述:
我想要得到的价格,这product的细节与此代码:跨度返回空空白
Document doc = Jsoup.connect(url).get();
Element productitem = doc.select("div.right-container._right-container").first();
Iterator<Element> price = productitem.select("div.price._product-price").iterator();
System.out.println(price.next().text());
that returns empty whitespace
也这样:
Elements span = doc.select("span");
System.out.println(spanText);
for (Element e:span)
System.out.println(e.text());
返回空,一切都只是价格。
即使只是这样的:
Element productitem = doc.select("div.right-container._right-container").first();
System.out.println(productitem);
将返回整条生产线<span>69.90</span>
到
是存在的一个原因,这个跨度是浏览器而不是Jsoup可见?
答
你如何检查HTML?由F12或通过查看源?因为当我去查看源代码,我可以看到有HTML中没有价格:
<div class="price _product-price" tabindex="0"> </div>
当我看着HTML通过F12:
当我看着HTML通过查看源代码:
因此,通过Jsoup返回的结果是正确的。
但是当我在这个文件中寻找价格(为我的国家是199.00),我可以找到行是这样的:
"isBuyable":true,"price":19900,"tags"
也许你应该尝试找到价格这种方式。
你可以分享html吗?我在url上找不到任何东西 – soorapadman
这正是浏览器检查元素上的点,它存在于jsoup中不可见 –
我在不同的国家它迫使选择国家并继续。 – soorapadman