curl javascript form completion

Discussion in 'Javascript' started by ynotssor, Apr 6, 2006.

  1. ynotssor

    ynotssor Guest

    Hello, can someone please tell me the correct way to use "curl" to complete
    an online form? I am trying to eventually retrieve my account balance via
    a cron job that will email me the parsed output of the web page that gets
    returned from the curl form completion.

    The page I am trying to access is https://retire.hartfordlife.com/index.html
    and the html block that contains the form is:

    <form method="post" name="form1"
    action="https://retire.hartfordlife.com/HartfordOnline/Login"><input
    type="hidden" name="target" value="MultiRole" /> <table width="100%"
    border="0" cellspacing="0" cellpadding="2" bgcolor="#e2e9f1">
    <tr>
    <td colspan="2"><font color="#000000" face="Verdana, Arial, Helvetica,
    sans-serif" size="3"><strong><font size="2">Hartford<em>Online</em>
    Login</font></strong></font></td>
    </tr>
    <tr>
    <td nowrap><font face="Verdana, Arial, Helvetica, sans-serif"
    size="2">User
    ID</font></td> <td><input type="text" size="18" name="user" tabindex="1"
    value=""/></td>
    </tr>
    <tr>
    <td><font face="Verdana, Arial, Helvetica, sans-serif"
    size="2">PIN</font></td> <td><input type="password" size="18"
    tabindex="2"
    name="password" value=""/></td>
    </tr>
    </table>
    <table width="100%" border="0" cellspacing="0" cellpadding="2"
    bgcolor="#e2e9f1">
    <tr>
    <td nowrap><a tabindex="4"
    href="https://retire.hartfordlife.com/HartfordOnline/ChallengePhrase"><fonts
    ize="1" face="Verdana, Arial, Helvetica, sans-serif">Forgot Your
    PIN?</font></a><font size="1" face="Verdana, Arial, Helvetica,
    sans-serif"><br /><a tabindex="5"

    href="HartfordOnline">https://retire.hartfordlife.com/Enrollment/Enroll">Har
    tfordOnline
    Enroll</a></font></td> <td><a tabindex="3"
    href="javascript:document.forms['form1'].submit()"><img src="imgs/lock.gif"
    width="13" height="16" border="0" title="ssl"><img src="imgs/login.gif"
    width="39" height="16" border="0" /></a>
    </td>
    </tr>
    </table>
    </form>

    I don't know how to handle the
    _href="javascript:document.forms['form1'].submit()"_ but what is failing to
    return the desired page is this command:

    /usr/bin/curl -A "Mozilla/4.0" -F user=myuser -F password=mypasswd \
    -F form1="https://retire.hartfordlife.com/HartfordOnline/Login" \
    -F target="MultiRole" https://retire.hartfordlife.com/index.html \
    > results.html


    I would really, really appreciate any help that anyone can offer about the
    correct curl command to use to complete this form.
    ynotssor, Apr 6, 2006
    #1
    1. Advertising

  2. ynotssor

    Ben C Guest

    On 2006-04-06, ynotssor <> wrote:
    > Hello, can someone please tell me the correct way to use "curl" to complete
    > an online form? I am trying to eventually retrieve my account balance via
    > a cron job that will email me the parsed output of the web page that gets
    > returned from the curl form completion.
    >
    > The page I am trying to access is https://retire.hartfordlife.com/index.html
    > and the html block that contains the form is:
    > [...]
    > I don't know how to handle the
    > _href="javascript:document.forms['form1'].submit()"_ but what is failing to
    > return the desired page is this command:


    I don't think the fact that the form is submitted with a JavaScript call
    to the DOM rather than by the browser's builtin way of handling an HTML
    "submit" button makes any difference, fortunately. What the server gets
    sent is the same, and that's the point at which curl steps in.

    > /usr/bin/curl -A "Mozilla/4.0" -F user=myuser -F password=mypasswd \
    > -F form1="https://retire.hartfordlife.com/HartfordOnline/Login" \
    > -F target="MultiRole" https://retire.hartfordlife.com/index.html \
    > > results.html

    >
    > I would really, really appreciate any help that anyone can offer about the
    > correct curl command to use to complete this form.


    I think I got most of the way there with this:

    curl -A "Mozilla/5.0 (X11; U; Linux i686; en-GB; rv:1.7.12) Gecko/20050920 Firefox/1.0.7" \
    -d "target=MultiRole&user=bla&password=bla" \
    https://retire.hartfordlife.com/HartfordOnline/Login > results.html

    Try it with your real username and password (where I've put "bla"). Your
    abbreviated user agent string may well be fine, but to be on the safe
    side I used exactly the same thing Firefox was using.

    You probably also will need to add the options "-a ./cookies -b
    ../cookies" because you may need cookies when it comes to actually
    interacting with the site properly.

    I think you want -d for the postdata, not -F. -F is for
    multipart/form-data data which is a different data format (usually used
    for file uploads). This form is just an urlencoded one, for which you
    use -d.

    A really good way of figuring these out is to use Firefox's "Tamper
    Data" extension, which lets you see exactly what it submitted to the
    server and exactly what came back.
    Ben C, Apr 12, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chris

    cURL in ASP.NET

    Chris, Dec 17, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    8,147
    Joerg Jooss
    Dec 19, 2004
  2. ß Ø ® G

    Page Curl Javascript wtd

    ß Ø ® G, Jan 26, 2004, in forum: HTML
    Replies:
    10
    Views:
    6,745
    supermann
    Jun 7, 2007
  3. curl and popen2

    , Feb 2, 2005, in forum: Python
    Replies:
    1
    Views:
    568
    Robey Holderith
    Feb 2, 2005
  4. post data using curl

    , Feb 12, 2007, in forum: Python
    Replies:
    0
    Views:
    371
  5. ziggs
    Replies:
    2
    Views:
    176
    Henry Robinson
    Apr 21, 2004
Loading...

Share This Page