0
我試圖從一個網站獲取特定的標籤。 我可以閱讀HTML,但無法獲取特定的標籤。 有什麼辦法可以做這個任務嗎? 我在其他線程中搜索,但我找不到解決方案。android:如何從html獲取標籤
在此先感謝。
這是代碼。
public class MainActivity extends Activity {
TextView text;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
text = (TextView)findViewById(R.id.text);
DownloadTask task = new DownloadTask();
task.execute("http://zodia.bg/sign/aries");
}
private class DownloadTask extends AsyncTask<String, Void, String>{
@Override
protected String doInBackground(String... urls) {
HttpResponse response = null;
HttpGet httpGet = null;
HttpClient mHttpClient = null;
String s = "";
try {
if(mHttpClient == null){
mHttpClient = new DefaultHttpClient();
}
httpGet = new HttpGet(urls[0]);
response = mHttpClient.execute(httpGet);
s = EntityUtils.toString(response.getEntity(), "UTF-8");
} catch (IOException e) {
e.printStackTrace();
}
return s;
}
@Override
protected void onPostExecute(String result){
text.setText(result);
}
}
}