I am trying to connect to a website and pull off some specific information. I was using HTMLCleaner and xpath but it doesnt seem to support all the xpath queries I need.
I am trying to use Jsoup now, after reading the good reviews. But the problem is whenever I run the program it force closes. Following is my trial program. Please let me know where I am going wrong. (I have Internet Permission set in the manifest file).
Thank you.
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import java.io.IOException;
public class jTrial extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
String myString = null;
super.onCreate(savedInstanceState);
setContentView(R.layout.search);
try{
Document doc = Jsoup.connect("http://google.com/").get();
Elements divs = doc.select("div");
for (Element div : divs) {
myString=div.text();
}
}
catch(IOException e){
myString=e.getMessage();
}
TextView tv=new TextView(this);
tv.setText(myString);
//this.setContentView(tv);
}
}
Thanks.