Reputation: 2327
I am writing simple Android application which parse html at specific positions, take some data and show in a ListView
. As app need only plain html response is there any possibility to request only plain html. How to exclude css and java script files, images and similar from http request?
I am using apache HttpClient
object.
Upvotes: 0
Views: 797
Reputation: 30581
Does this answer your question? If so, remember to perform this on a separate thread to avoid UI blocking (probably want to use AsyncTask)
(From How to get the html-source of a page from a html link in android?)
HttpClient client = new DefaultHttpClient();
HttpGet request = new HttpGet(url);
HttpResponse response = client.execute(request);
String html = "";
InputStream in = response.getEntity().getContent();
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
StringBuilder str = new StringBuilder();
String line = null;
while((line = reader.readLine()) != null)
{
str.append(line);
}
in.close();
html = str.toString();
Upvotes: 1