可能重複:
Is it possible to get the HTML code from WebView獲取一個網頁的HTML中的Android
我試圖使這需要得到來自網站的HTML代碼的應用程序,並經過代碼來尋找圖像。我現在在哪裏給了我一個模擬器中的html代碼,但是當我在我的計算機上打開網站的源代碼時,它是一個不同的代碼。
public String getInternetData(String adresse) throws Exception{
BufferedReader in = null;
String data = null;
try{
HttpClient client = new DefaultHttpClient();
URI website = new URI(adresse);
HttpGet request = new HttpGet();
request.setURI(website);
HttpResponse response = client.execute(request);
in = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
StringBuffer sb = new StringBuffer("");
String l = "";
String nl = System.getProperty("line.separator");
while ((l = in.readLine()) !=null){
sb.append(l + nl);
}
in.close();
data = sb.toString();
return data;
}finally{
if (in != null){
try{
in.close();
return data;
}catch (Exception e){
e.printStackTrace();
}
}
}
}
我在模擬器中得到的代碼以一些關於啓用JavaScript和Cookie的事情結束。如果這是我的問題,我該如何解決它?
任何幫助將不勝感激!