T
Tim Frangioso
Hi All,
I know this subject has been discussed on this newsgroup. I have researched
previous answers and I am bewildered.
I am trying to log into
"http://unabridged.merriam-webster.com/noauth/login.php" so I can access the
dictionary definitions programmatically.
The form looks like this:
<form name=access method=post
action="http://unabridged.merriam-webster.com/noauth/login.php">
User Name: <input type=text name=usermail size=30 maxlength=80 value=""><br>
Password: <input type=password name=userpass size=20 maxlength=20>
<div align=right>
<input type=checkbox name=savepass value=checked checked> save log-in
information
<input type=hidden name=nocookies value="">
<input type=hidden name=enterkey value="hit">
<input type="submit" name=userlogin value="Log in"> </div>
</form>
Here is the code that I am using:
************************Begin Code**********************************
String usermail = "usermail="+URLEncoder.encode("(e-mail address removed)",
"UTF-8");
String userpass = "userpass="+URLEncoder.encode("tfrangio", "UTF-8");
URL location = new
URL("http://unabridged.merriam-webster.com/noauth/login.php");
HttpURLConnection currentUrlCon =
(HttpURLConnection)location.openConnection();
currentUrlCon.setAllowUserInteraction(true);
currentUrlCon.setRequestMethod("POST");
String body = usermail + "&" + userpass;
currentUrlCon.setRequestProperty( "Content-Length", ""+body.length());
currentUrlCon.setRequestProperty("Content-type",
"application/x-www-form-urlencoded");
currentUrlCon.setDoOutput(true);
//write the request
PrintWriter pw = new PrintWriter(currentUrlCon.getOutputStream());
pw.write(body);
pw.flush();
pw.close();
//Printout response
BufferedReader currentMsg = new BufferedReader(new
InputStreamReader(currentUrlCon.getInputStream()));
completeLine = "";
while ( (inputLine = currentMsg.readLine()) != null) {
completeLine += inputLine; }
System.out.println("HTML returned=\n"+completeLine);
//short verification of 1st POST
System.out.println("response="+currentUrlCon.getResponseCode()+"/"+currentUr
lCon.getResponseMessage());
********************************End Code******************************
I have tried listing out all the other parameters and values for the form
but, none of them worked.
For example I passed in the following for the value for the body string:
"usermail=tfrangio%40acm.org&userpass=tfrangio&enterkey=hit&userlogin=Log+in
"
I have also tried this:
"usermail=tfrangio%40acm.org&userpass=tfrangio&savepass=checked&nocookies=&e
nterkey=hit&userlogin=Log+in"
Thinking that maybe the handling code dies on the server side when it can
not find the correct value for a parameter.
Any other ideas on what I doing wrong?
Thanks,
-Tim
I know this subject has been discussed on this newsgroup. I have researched
previous answers and I am bewildered.
I am trying to log into
"http://unabridged.merriam-webster.com/noauth/login.php" so I can access the
dictionary definitions programmatically.
The form looks like this:
<form name=access method=post
action="http://unabridged.merriam-webster.com/noauth/login.php">
User Name: <input type=text name=usermail size=30 maxlength=80 value=""><br>
Password: <input type=password name=userpass size=20 maxlength=20>
<div align=right>
<input type=checkbox name=savepass value=checked checked> save log-in
information
<input type=hidden name=nocookies value="">
<input type=hidden name=enterkey value="hit">
<input type="submit" name=userlogin value="Log in"> </div>
</form>
Here is the code that I am using:
************************Begin Code**********************************
String usermail = "usermail="+URLEncoder.encode("(e-mail address removed)",
"UTF-8");
String userpass = "userpass="+URLEncoder.encode("tfrangio", "UTF-8");
URL location = new
URL("http://unabridged.merriam-webster.com/noauth/login.php");
HttpURLConnection currentUrlCon =
(HttpURLConnection)location.openConnection();
currentUrlCon.setAllowUserInteraction(true);
currentUrlCon.setRequestMethod("POST");
String body = usermail + "&" + userpass;
currentUrlCon.setRequestProperty( "Content-Length", ""+body.length());
currentUrlCon.setRequestProperty("Content-type",
"application/x-www-form-urlencoded");
currentUrlCon.setDoOutput(true);
//write the request
PrintWriter pw = new PrintWriter(currentUrlCon.getOutputStream());
pw.write(body);
pw.flush();
pw.close();
//Printout response
BufferedReader currentMsg = new BufferedReader(new
InputStreamReader(currentUrlCon.getInputStream()));
completeLine = "";
while ( (inputLine = currentMsg.readLine()) != null) {
completeLine += inputLine; }
System.out.println("HTML returned=\n"+completeLine);
//short verification of 1st POST
System.out.println("response="+currentUrlCon.getResponseCode()+"/"+currentUr
lCon.getResponseMessage());
********************************End Code******************************
I have tried listing out all the other parameters and values for the form
but, none of them worked.
For example I passed in the following for the value for the body string:
"usermail=tfrangio%40acm.org&userpass=tfrangio&enterkey=hit&userlogin=Log+in
"
I have also tried this:
"usermail=tfrangio%40acm.org&userpass=tfrangio&savepass=checked&nocookies=&e
nterkey=hit&userlogin=Log+in"
Thinking that maybe the handling code dies on the server side when it can
not find the correct value for a parameter.
Any other ideas on what I doing wrong?
Thanks,
-Tim