2011-10-05 114 views
4

我正在使用JSoup下載和解析Android問題頁面。這是我的代碼到目前爲止:JSoup不解析Android已知問題頁面

URL url = null; 
    try { 
     url = new URL(
       "http://www.google.com/support/androidmarket/developer/bin/static.py?page=known_issues.cs"); 
    } catch (MalformedURLException e) { 
     // TODO Auto-generated catch block 
     e.printStackTrace(); 
    } 
    try { 
     Document document = Jsoup.parse(url, 5000); 
     EditText bla; 
     bla = (EditText) this.findViewById(R.id.editText1); 
     bla.setText(document.toString()); 
     if (document.toString().contains("recentfixes")) { 
      Toast.makeText(this, "YES", 1).show(); 
     } 

那麼,奇怪的是,整個頁面被解析,但最近的修復部分。 This是wget輸出,this是解析輸出。

你能幫我嗎?

+0

是否有任何其他HTML解析器,你可以試試嗎?我發現http://htmlcleaner.sourceforge.net/非常強大。 –

+0

謝謝,我會嘗試一個:) – Force

+0

不,它不解析最近的修復......這很奇怪。 – Force

回答

0

嘗試使用.connect來代替。

下應該給你整個頁面的文字:

URL url = null; 
try { 
    url = new URL(
      "http://www.google.com/support/androidmarket/developer/bin/static.py?page=known_issues.cs"); 
} catch (MalformedURLException e) { 
    e.printStackTrace(); 
} 
try { 
    Document document = Jsoup.connect(url).timeout(0).get(); 
    String entireText = document.text(); 
} catch (IOException e) { 
    e.printStackTrace(); 
} 
+0

問題出自2011年10月,只是想你應該知道。 –

+0

爲後人而回答。 – bean