我正在尝试显示从网站上获取的特定号码,但我找不到这样做的方法。例如,在有倒计时的网站中,我希望能够读取该数字并将其显示在我的应用中。这甚至可能吗? 这是我在java中的内容:
protected void onCreate(Bundle savedInstanceState) {
try{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_second);
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
TextView textview = (TextView) findViewById(R.id.textView3);
try {
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://counter.onlineclock.net/");
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
InputStream webs = entity.getContent();
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(webs, "iso-8859-1"),8);
textview.setText(reader.readLine());
webs.close();
}catch(Exception e){
Log.e("log_tag", "Error converting result " + e.toString());
}
}catch(Exception e){
Log.e("log_tag", "Error in http connection " + e.toString());
}
}
catch(Exception e){
Log.e("ERROR", "ERROR IN CODE: " + e.toString());
e.printStackTrace();
}
我想从该网站上阅读“柜台”,但我不知道怎么办?有解决方案吗 谢谢你的阅读。