Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

lwp error: Receiving http 500 error when submitting.....

by Qish (Initiate)
on Nov 06, 2003 at 01:45 UTC ( [id://304919]=perlquestion: print w/replies, xml ) Need Help??

Qish has asked for the wisdom of the Perl Monks concerning the following question:

Hi Im working on a perl lwp browser that will allow me to automate my login to my aol email account. Heres the html source of the website (my code is under it)
" +ancel=y&triedAimAuth=y" : <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1 +"> <HTML> <HEAD> <title>Screen Name Service</title> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF8CONV_P +LACEHOLDER"> <SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript"> </SCRIPT> <SCRIPT LANGUAGE="JavaScript" SRC="/mcLib.js.psp"></SCRIPT> <LINK REL="stylesheet" TYPE="text/css" HREF="/style/snsStyles.css"> <style type="text/css"> .snsSmallText { color: #000000 } .snsSmallTextBold { color: #000000 } .snsSmallTextLink { color: #003366 } .snsSmallTextBoldLink { color: #003366 } .snsSmallestText { color: #000000 } .snsMediumText { color: #000000 } .snsMediumTextBold { color: #000000 } .snsMediumTextBoldLink { color: #003366 } .snsHeadline { color: #000000 } .snsFieldLabel { color: #000000 } .snsFieldSubtext { color: #0066FF } </style> </HEAD> <BODY TOPMARGIN="15" LEFTMARGIN="60" MARGINHEIGHT="15" MARGINWIDTH="60 +"> <TABLE WIDTH="585" BORDER="0" CELLPADDING="0" CELLSPACING="0"> <TR> <TD COLSPAN="3" ALIGN="left" VALIGN="bottom"><IMG SRC="http://webmail." ALT="Partner Image" H +EIGHT="45" WIDTH="345" VSPACE="5"></TD> </TR> <TR> <TD> <TABLE WIDTH="365" BORDER="0" CELLPADDING="0" CELLSPACING="0" BGCOLOR= +"#003366"> <tr> <td><img src="/images/dot.gif" height=1 width=1></td> <td><img src="/images/dot.gif" height=1 width="130"></td> <td><img src="/images/dot.gif" height=1 width="233"></td> <td><img src="/images/dot.gif" height=1 width=1></td> </tr> <TR> <TD WIDTH="1" ROWSPAN="6"><IMG SRC="/images/transparentgif.gif"></TD> <TD> <a href="java_script_:popHomePage('/_cqr/homePg/hpController/controlle +r.psp?siteId=snshomepage');"><IMG SRC="/images/sns_module_logo.gif" W +IDTH="125" HEIGHT="15" alt="Screen Name Service" vspace=5 border=0></ +a></TD> <TD ALIGN="RIGHT"> <table border=0 cellspacing=0 cellpadding=0> <tr> <td> <A HREF="java_script_:popHomePage('/_cqr/homePg/hpController/controlle +r.psp?siteId=snshomepage');" class="snsNavbar"><IMG SRC="/images/t_Ma +in.gif" width=33 height=16 alt="Main" border=0></A></td> <td><A HREF="java_script_:popHomePage('/_cqr/homePg/hpController/contr +oller.psp?hpState=hpHelp&siteId=snshomepage');" class="snsNavbar"><IMG SRC="/images/t_Help.gif" width=31 height=16 alt +="Help" border=0></A></td> </tr> </table> </TD> <TD WIDTH="1" ROWSPAN="6"><IMG SRC="/images/transparentgif.gif"></TD> </TR> <TR> <TD COLSPAN="2" ALIGN="CENTER" VALIGN="MIDDLE" BGCOLOR="lightgrey"></t +d> </TR> <tr> <td colspan=2 BGCOLOR="#FFFFFF"><img src="/images/dot.gif" height=5></ +td> </tr> <TR> <TD COLSPAN="2" ALIGN="LEFT" VALIGN="MIDDLE" BGCOLOR="#FFFFFF"> <SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript"> <!-- function validateSigninForm() { // this checks the screenname value first // and then if that's ok, it checks that the password isn't empty if (mcCheckScreenName(document.signinForm.screenname.value, 1, 'A vali +d Screen Name consists of 3-16 characters and can contain letters, nu +mbers, spaces, and must start with a letter (e.g., john doe123). Plea +se re-type your Screen Name.')) { var password = document.signinForm.password.value; if ((password == null) || (password == "")) { alert("You entered a password that is either too short or too long. Pl +ease enter a password that is 4-16 characters in length."); return false; } else { return true; } } else { return false; } } //--> </SCRIPT> <FORM METHOD="POST" NAME="signinForm" ACTION="" onSubmit="return validateSigninForm();"> <input type="hidden" name="charset" value="iso-8859-1"> <INPUT TYPE="HIDDEN" NAME="siteState" VALUE=""> <INPUT TYPE="HIDDEN" NAME="siteId" VALUE="atlasaol"> <INPUT TYPE="HIDDEN" NAME="newSN" value="0"> <INPUT TYPE="HIDDEN" NAME="mcState" value="initialized"> <INPUT TYPE="HIDDEN" NAME="authLev" value="2"> <INPUT TYPE="HIDDEN" NAME="submitSwitch" VALUE="1"> <INPUT TYPE="HIDDEN" NAME="triedAimAuth" VALUE="y"> <table width="363" border=0 cellpadding=0 cellspacing=0> <tr valign="top"> <td rowspan=4 width="20">&nbsp;</td> <td colspan=2 width="157"> <div class="snsHeadline">Sign In</div> <div style="line-height: 10px;">&nbsp;</div> <div class="snsFieldLabel">Screen Name </div> <INPUT TYPE="TEXT" NAME="screenname" SIZE="16" VALUE="" MAXLENGTH="16" + tabindex=1> <div class="snsFieldSpacer">&nbsp;</div> <div class="snsFieldLabel">Password</div> <INPUT TYPE="PASSWORD" NAME="password" SIZE="16" VALUE="" MAXLENGTH=16 + tabindex=2><br> <A HREF="/_cqr/login/login.psp?cf=lost&siteId=atlasaol&mcState=initial +ized&authLev=2" class="snsSmallTextLink">I forgot my password.</A> <div class="snsFieldSpacer">&nbsp;</div> </td> <td rowspan=3 width="10">&nbsp; </td> <td rowspan=3 width="166"> <div class="snsMediumTextBold">Signing in is easy!</div> <div class="snsSmallText"> Sign into our network of sites with your Screen Name and Password. <a href="java_script_:mcInfoPopUp(0, 'help.title','help.question1');" +class="snsSmallTextLink">learn more</a>. </div> <p> <div class="snsSmallTextBold"> You have a <a href="java_script_:mcInfoPopUp(0, 'help.title','help.que +stion5');" class="snsSmallTextBoldLink">Screen Name</a> if you use: </div> <div class="snsSmallText">America Online<BR>Compuserve 2000<BR>AIM<BR> +Netscape<BR></div> </td> <td rowspan=4 width="10">&nbsp;</td> </tr> <tr valign="top"> <td width=10> </td> <td width=147> </td> </tr> <tr valign="top"> <td colspan=2 valign="bottom"> <INPUT TYPE="SUBMIT" VALUE="Sign In" tabindex=4>&nbsp; <INPUT TYPE="BUTTON" VALUE="Cancel" onClick="document.location='/_cqr/ +login/loginCancel.psp?siteId=atlasaol&siteState=';" tabindex=5> </td> </tr> <tr valign="top"> </tr> </table> <SCRIPT LANGUAGE="JavaScript"> <!-- function mcIsNav47() { if (navigator.appName != 'Netscape' || (navigator.appVersion.substring +(0,3) != '4.7' && navigator.userAgent.indexOf('NSCP') == -1)) { return 0; } else { return 1; } } function setFieldFocus() { document.signinForm.screenname.focus(); } if (mcIsNav47() == 0) { // set the focus now, and again when the page is done // just in case anything steals focus from this field document.signinForm.screenname.focus(); window.onload = setFieldFocus; } //--> </SCRIPT> </TD> </TR> <tr> <td colspan=2 BGCOLOR="#FFFFFF"><img src="/images/dot.gif" height=8></ +td> </tr> <TR> <td><p class="snsNavbar"><IMG SRC="/images/b_ScreenNameService.gif" wi +dth=130 height=16 alt="Screen Name Service"></p></td> <TD align="right"><table border=0 cellspacing=0 cellpadding=0 width="2 +33"> <tr> <td><A HREF="java_script_:mcInfoPopUp(1, '/help/privacyPolicy.psp?site +Id=atlasaol');" class="snsNavbar"><IMG SRC="/images/b_PrivacyPolicy.g +if" width=83 height=16 hspace=0 border=0 alt="Privacy Policy"></A></td> <td><A HREF="java_script_:mcInfoPopUp(1, '/help/terms.psp?siteId=atlas +aol');" class="snsNavbar"><IMG SRC="/images/b_TermsofUse.gif" width=7 +8 height=16 hspace=0 border=0 alt="Terms of Use"></A></td> <td><A HREF="java_script_:mcInfoPopUp(1, '/help/securityTip.psp?siteId +=atlasaol');" class="snsNavbar"><IMG SRC="/images/b_SecurityTip.gif" +align="right" width=72 height=16 hspace=0 border=0 alt="Security Tip"></A></td> </tr> </table></TD> </TR> <tr> <td colspan=4><img src="/images/dot.gif" height=5></td> </tr> </TABLE> </form> </TD> <TD WIDTH="20">&nbsp;</TD> <TD VALIGN="TOP" WIDTH="200"> <div class="snsSmallText"><b>AOL Members:</b> To sign in and access yo +ur AOL Mail, enter your AOL Screen Name and password.<br><br> AOL Any +where gives you the ability to access your AOL Mail whenever you're c +onnected to the World Wide Web. </div> </TD> </TR> </TABLE> </BODY> </HTML>

I have all the variable names figured out.. however Im having trouble assigning a variable name to the submit value. Someone told me not to worry about it and send everything else, but that returned an http 500 error, which signifies the cgi script didnt run. Im thinking thats because it wasnt submitted properly??.. I dont know... heres the code for the lwp program

<br> use strict; my $outfile = "result_test.html"; use LWP; my $browser = LWP::UserAgent->new; $browser->cookie_jar( {} ); my $response = $browser->post( '', [ "charset" => "iso-8859-1", "siteState" => "", "siteId" => "atlasaol", "newSN" => "0", "mcState" => "initialized", "authLev" => "2", "submitSwitch" => "1", "triedAimAuth" => "y", "screenname" => "kmcp12", "password" => "notmypassword", ] ); die "Error: ", $response->status_line, "\n" unless $response->is_success; open(OUT, "$outfile") || die "Can't write-open $outfile: $!"; binmode(OUT); print OUT $response->content; close(OUT); print "Bytes saved: ", -s $outfile, " in $outfile\n";


I dont know what to do about this line from the html source

" <INPUT TYPE="SUBMIT" VALUE="Sign In" tabindex=4>  "

I think thats the problem... Please help.

janitored by ybiC: Balanced <readmore> tags around sample markup and code

Replies are listed 'Best First'.
Re: lwp error: Receiving http 500 error when submitting.....
by tcf22 (Priest) on Nov 06, 2003 at 03:49 UTC
    There may be more going on in the backend then you can tell. Passing a SUBMIT value won't do you any good, because there is no name="" parameter in the tag, so it won't get passed anyway(at least on most browsers that I've seen).

    Have a look at WWW::Mechanize. It may make this task a little easier.

    - Tom

Re: lwp error: Receiving http 500 error when submitting.....
by Roger (Parson) on Nov 06, 2003 at 02:06 UTC
    Perhaps you should consider posting just a link to the URL instead of posting the HTML source here.

    I think you need to add
    "Sign In" => "SUBMIT"
    to your post command. See if that fixes the problem.


Re: lwp error: Receiving http 500 error when submitting.....
by Nitrox (Chaplain) on Nov 06, 2003 at 14:11 UTC
    You're POST'ing to a non-SSL site:

    Their form posts to an SSL address: ACTION=""

    Do they allow non-SSL logins?


Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://304919]
Approved by Roger
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2024-07-21 23:48 GMT
Find Nodes?
    Voting Booth?

    No recent polls found

    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.