hi,

lets say there is a web page requesting,
-personalID
-sequence of numbers (written image, but assume its just plain text)


i can parse and get the sequence, however i dont know how to post form with the 
values?

(the sequence in post method changes)


here is the code, any help would be appreciated..


importorg.apache.commons.httpclient.HttpClient;importorg.apache.commons.httpclient.NameValuePair;importorg.apache.commons.httpclient.cookie.CookiePolicy;importorg.apache.commons.httpclient.methods.GetMethod;importorg.apache.commons.httpclient.methods.PostMethod;public
String contents=
String urlAddress = 
HttpClient client = 
client.getParams().setCookiePolicy(
CookiePolicy.
* String key = "";
* 
* URL url = new URL(urlAddress); URLConnection conn =
* url.openConnection(); DataInputStream in = new
* DataInputStream(conn.getInputStream()); BufferedReader d = new
* BufferedReader(new InputStreamReader(in)); StringBuffer buffer =
* new StringBuffer(); while (d.ready()) {
* buffer.append(d.readLine()); }
* 
* int index = -1; String contents = buffer.toString(); index =
* contents.indexOf("mp3sesler"); while (index > -1) { key = key +
* contents.substring(index + 10, index + 11); index =
* contents.indexOf("mp3sesler", index + 11); }
* 
* System.out.println(contents); System.out.println(key);
*/classClient {publicstaticvoidmain(String[] args) {try{intstatusCode, 
index;"", 
key="";"http://app.sgk.gov.tr/SigortaliHizmet/jsp/tcGir.jsp";newHttpClient();BROWSER_COMPATIBILITY);/*GetMethod
 getMethod = 
getMethod.getParams().setCookiePolicy(CookiePolicy.
statusCode = client.executeMethod(getMethod);
contents = getMethod.getResponseBodyAsString();
getMethod.releaseConnection();
index = -1;
index = contents.indexOf(
key = key + contents.substring(index + 10, index + 11);
index = contents.indexOf(
}
System.
System.
}
PostMethod postMethod = 
NameValuePair[] data = { 
postMethod.addParameters(data);newGetMethod(urlAddress);RFC_2109);if(statusCode 
!= -1) {"mp3sesler");while(index > -1) {"mp3sesler", index + 
11);out.println(contents);out.println(key);newPostMethod(urlAddress);newNameValuePair("tckno",
 "11111111111"),newNameValuePair("akey", 
key),newNameValuePair("tcknodanSicilOgren", 
"tcknovar"),newNameValuePair("sorgu1", "Sigortalı Ara") };// Configure the form 
parameters* method.addParameter("tckno", "11111111111");
* method.addParameter("akey", "4113");
* method.addParameter("tcknodanSicilOgren", "tcknovar");
* method.addParameter("sorgu1", "Sigortalı Ara");
*//*// Execute the POST methodstatusCode = client.executeMethod(postMethod);
contents = postMethod.getResponseBodyAsString();
postMethod.releaseConnection();
System.
}
} 
e.printStackTrace();
}
}if(statusCode != -1) {out.println(contents);catch(Exception e) { 




---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to