首先添加依赖: compile 'org.jsoup:jsoup:1.9.2' 还需要网络权限
代码如下 protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); initView(); mTextView.setOnClickListener(this); } private void initView() { mTextView = (TextView) findViewById(R.id.textView); } @Override public void onClick(View view) { new Thread(){ @Override public void run() { try { //从一个URL加载一个Document对象。 Document doc = Jsoup.connect("http://www.weather.com.cn/weather/101010100.shtml").get(); //集合 Elements elements = doc.select("div.c7d").select("input"); //遍历打印 Log.i("mytag",elements.get(0).attr("value")); Elements elements1 = doc.select("div.c7d").select("p"); Log.i("mytag",elements1.get(0).attr("title")); }catch(Exception e) { Log.i("mytag", e.toString()); } } }.start(); } }