Witam
Potrzebuję stworzyć funkcję która odczyta tylko zawartość strony (bez elementów HTML). Narazie mój kod działa tak, że wysyła do serwera PHP dwie zmienne POST i wypisuje przetworzone dane, jednak BufferedReader pobiera dodatkowo cały kod źródłowy strony. Kompletnie nie mam pomysłu jak to zmienić. Przepatrzyłem sporą część internetu ale nigdzie nie znalazłem odpowiedzi na moje pytanie.
Kod
@Override
protected Void doInBackground(Void... params)
{
try
{
Thread.sleep(50);
EditText Login = (EditText)findViewById(R.id.login);
HttpURLConnection connection;
OutputStreamWriter request = null;
URL url = null;
String parameters = "l=" + lString + "&p=" + pString;
try
{
url = new URL("http://www.moingas.cba.pl/index.php");
connection = (HttpURLConnection) url.openConnection();
connection.setDoOutput(true);
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
connection.setRequestMethod("POST");
request = new OutputStreamWriter(connection.getOutputStream());
request.write(parameters);
request.flush();
request.close();
String line = "";
InputStreamReader isr = new InputStreamReader(connection.getInputStream());
BufferedReader reader = new BufferedReader(isr);
StringBuilder sb = new StringBuilder();
while ((line = reader.readLine()) != null)
{
sb.append(line + "\n");
}
response = sb.toString();
isr.close();
reader.close();
}
catch(IOException e)
{
}
}
catch (InterruptedException e)
{
}
return null;
}
Liczę na waszą pomoc :)