android parse web page - jsoup. use in intelliJ IDE

android parse web page – jsoup. use in intelliJ IDE

now you can parse web page like jQUery, “jsoup”.

install jsoup,

Download jsoup jar, and import to your project. save jsoup.jar in libs folder in your project.

open intelliJ.

  • project, right click -> module
  • add, select “jar or directories”
  • import from libs folder jars.

usage

Before start coding, edit AndroidManifest.xml, enable internet permission. insert line before Application tag.

<uses-permission android:name="android.permission.INTERNET" /><br></br>

code

when we want to access web page by URL, have to use thread to process this task, so i use AsyncTask for query web page.

class testAsynch extends AsyncTask
{
protected String doInBackground(Void...arg0) {
Log.d("DoINBackGround","On doInBackground...");

try {
Document doc = Jsoup.connect("http://jsoup.org").get();
Log.d("info", doc.title());
} catch (IOException e) {
e.printStackTrace();
}
return "You are at PostExecute";
}
}

execute in your activity.java,

new testAsynch().execute();

CaesarChi

Web developer, focus on website fullstack, special JavaScript, and love sharing developing experience and communicate with developers. http://about.me/clonn