Document doc = Jsoup.connect("http://reviews.opentable.com/0938/9/reviews.htm").get();
Element part = doc.body();
Elements parts = part.getElementsByTag("span");
String attValue;
String html;
for(Element ent : parts)
{
if(ent.hasAttr("class"))
{
attValue = ent.attr("class");
if(attValue=="BVRRReviewText description")
{
System.out.println("\n");
html=ent.text();
System.out.println(html);
}
}
}
上述程序正在使用Jsoup.jar。HTML解析使用Jsoup.Jar
我正在訪問該網頁,我的目標是打印標籤<span class="BVRRReviewText description">text</span>
中的文本。
但是沒有任何內容被打印爲輸出。在程序中沒有添加到String html
的內容。但attValue
正在獲取span標籤的所有屬性值。
我該在哪裏出錯?請指教。
感謝....只是得到了解決? – LGAP 2010-11-12 08:58:51