I tryed to write an app that posts a form to a website and then gets the result which will later be used in Jsoup, but everytime the app is run I get the same website back as a result. The website:Link
I used this for an example:Link
I saw somewhere on this site that you have to put an action with the url but this doesn't work either.
Part of my app:
protected String doInBackground(String... params) {
String url = "http://www.ap-ljubljana.si/vozni_red2/VR1.php";
HttpPost post = new HttpPost(url);
List<NameValuePair> parameters = new ArrayList<NameValuePair>();
parameters.add(new BasicNameValuePair("VSTOP_IME", vhod));
parameters.add(new BasicNameValuePair("IZSTOP_IME", izhod));
try {
UrlEncodedFormEntity entity = new UrlEncodedFormEntity(parameters);
HttpClient client = new DefaultHttpClient();
post.setEntity(entity);
HttpResponse response = client.execute(post);
html_response = EntityUtils.toString(response.getEntity());
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
}
Change your url from
String url = "http://www.ap-ljubljana.si/vozni_red2/VR1.php/";
to
String url = "http://www.ap-ljubljana.si/vozni_red2/VR2.php";
Remove String action;
Thats all.
The action parameter is there to tell the 'form' to which url to post the data to. If the action parameter is empty or missing then the form will post to the same url as it's page.