嗨,我真的很新的編碼。我試圖從一個特定的網站http://www.rfebs.es/estadisticas/2017/liga/B_res.php拉文本(HTML)使用jsoup,但我似乎無法做到這一點。這裏是我的代碼,提前謝謝!Jsoup代碼不能正常工作
package davidgb.baseballspain;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
public class MainActivity extends AppCompatActivity {
TextView texx;
Document doc;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
texx=(TextView)findViewById(R.id.textp);
Button but1 = (Button)findViewById(R.id.but);
but1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
new doit().execute();
}
});
}
public class doit extends AsyncTask<Void, Void, Void> {
String words;
@Override
protected Void doInBackground(Void... params) {
try {
doc = Jsoup.connect("http://www.rfebs.es/estadisticas/2017/liga/B_res.php").get();
words= doc.text();
} catch (Exception e) {
e.printStackTrace();
}return null;
}
@Override
protected void onPostExecute(Void aVoid) {
super.onPostExecute(aVoid);
texx.setText(words);
}
}
}
出了什麼問題? – bc004346