how to use Perl to input username and password for website?

Discussion in 'Perl Misc' started by Paul, Aug 15, 2005.

  1. Paul

    Paul Guest

    hi, greetings,

    I am trying to write a script to log on
    https://membership.dell.com/DellLogin/GA/login.aspx, so I can track my
    order instantly without log on the site each time.
    here is the scripts i wrote, but seems it does not work.

    can somebody give me some ideas? thanks.

    paul

    #!/usr/bin/perl


    use strict;
    use warnings;
    use LWP 5.64;

    my $browser = LWP::UserAgent->new;
    my $sbresponse;

    my $sburl = 'https://membership.dell.com/DellLogin/GA/login.aspx';

    #############Get the _viewstate##################
    $sbresponse = $browser->get($sburl);
    print "Error at $sburl\n ", $sbresponse->status_line, "\n Aborting"
    unless $sbresponse->is_success;


    my $sbident = 'name="__VIEWSTATE" value="';
    my $sbpos1 = index($sbresponse->content, $sbident) + length $sbident;
    my $sbpos2 = index $sbresponse->content, '"', $sbpos1;
    my $sbviewstate=substr($sbresponse->content, $sbpos1,
    $sbpos2-$sbpos1);
    #############Get _viewstate ends###################


    $sbresponse = $browser->post( $sburl,
    [ _txtUserName => '',
    _txtPassword => 'xxxx',
    __EVENTTARGET=>'subBtn',
    __EVENTARGUMENT=>'',
    __VIEWSTATE=>$sbviewstate,
    ]
    );
    print $sbresponse->content;
    Paul, Aug 15, 2005
    #1
    1. Advertising

  2. Paul

    Paul Lalli Guest

    Paul wrote:
    > hi, greetings,
    >
    > I am trying to write a script to log on
    > https://membership.dell.com/DellLogin/GA/login.aspx, so I can track my
    > order instantly without log on the site each time.
    > here is the scripts i wrote, but seems it does not work.


    "Does not work" is the worst possible error description. How does it
    not work? What does it do that you didn't expect, or what does it not
    do that you did expect? Does it crash? Does it not compile? Did your
    computer decide to leap out the window on its own accord? Did it print
    "I will not contact this website" fifty times? *What Happened*?

    > can somebody give me some ideas? thanks.
    >
    > paul
    >
    > #!/usr/bin/perl
    >
    >
    > use strict;
    > use warnings;
    > use LWP 5.64;
    >
    > my $browser = LWP::UserAgent->new;
    > my $sbresponse;
    >
    > my $sburl = 'https://membership.dell.com/DellLogin/GA/login.aspx';
    >
    > #############Get the _viewstate##################
    > $sbresponse = $browser->get($sburl);
    > print "Error at $sburl\n ", $sbresponse->status_line, "\n Aborting"
    > unless $sbresponse->is_success;


    So.... if something went wrong, you print an error message and then
    continue as though nothing went wrong?

    > my $sbident = 'name="__VIEWSTATE" value="';
    > my $sbpos1 = index($sbresponse->content, $sbident) + length $sbident;
    > my $sbpos2 = index $sbresponse->content, '"', $sbpos1;
    > my $sbviewstate=substr($sbresponse->content, $sbpos1,
    > $sbpos2-$sbpos1);
    > #############Get _viewstate ends###################


    Did you try printing any of these variables out to confirm they are
    what you think they are? Where is your debugging output? What
    attempts have you made to solve this problem on your own?

    > $sbresponse = $browser->post( $sburl,
    > [ _txtUserName => '',
    > _txtPassword => 'xxxx',
    > __EVENTTARGET=>'subBtn',
    > __EVENTARGUMENT=>'',
    > __VIEWSTATE=>$sbviewstate,
    > ]
    > );
    > print $sbresponse->content;


    You checked the get() above for errors. Why aren't you checking this
    post() for errors as well?


    Paul Lalli
    Paul Lalli, Aug 15, 2005
    #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. Steve Kallal
    Replies:
    9
    Views:
    173
    Joe Kaplan \(MVP - ADSI\)
    Jun 9, 2005
  2. Replies:
    5
    Views:
    163
    Bob Barrows [MVP]
    Dec 1, 2005
  3. John
    Replies:
    13
    Views:
    340
  4. Sam S.
    Replies:
    2
    Views:
    185
    Tad McClellan
    Feb 9, 2005
  5. Replies:
    1
    Views:
    128
    Michael Austin
    Apr 17, 2009
Loading...

Share This Page