autosubmit login and capture result - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

autosubmit login and capture result

blackcharlieblackcharlie Posts: 4Member
i'm looking to run this simple program ( on a different url - which happens to be a login page ). I pass in a valid login & pw, but the content is that of the login page, not the page i'm redirected to when I submit the same info from a browser. please help..

use HTTP::Request::Common qw(POST);
use LWP::UserAgent;

$ua = LWP::UserAgent->new();
my $req = POST 'http://www.perl.com/cgi-bin/cpan_mod',
[ module => 'DB_File', readme => 1 ];
$content = $ua->request($req)->as_string;
print "content: $content
";


Comments

  • JonathanJonathan Posts: 2,914Member
    : i'm looking to run this simple program ( on a different url - which
    : happens to be a login page ). I pass in a valid login & pw, but
    : the content is that of the login page, not the page i'm redirected
    : to when I submit the same info from a browser. please help..
    Hmmm...it may be that you need to pass more than just the login and password. For example, the login button itself and any hidden fields will also need to be passed. Many scripts look for the login button parameter to decide whether this is an attempt to log in or a request for the login page.

    Jonathan


    ###
    for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");

  • blackcharlieblackcharlie Posts: 4Member
    : : i'm looking to run this simple program ( on a different url - which
    : : happens to be a login page ). I pass in a valid login & pw, but
    : : the content is that of the login page, not the page i'm redirected
    : : to when I submit the same info from a browser. please help..
    : Hmmm...it may be that you need to pass more than just the login and password. For example, the login button itself and any hidden fields will also need to be passed. Many scripts look for the login button parameter to decide whether this is an attempt to log in or a request for the login page.
    :
    : Jonathan
    :
    :
    : ###
    : for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    : (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    : /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");
    :
    :


    i was trying to determine if a cookie was the problem & it does seem to be part of it. with cookies prompted, it does tell me it will write one. the thing now is it writes like 20 .gif files & a couple .js files & a .css file. I found this:


    use HTTP::Cookies::Netscape;
    use HTTP::Request::Common qw(POST);
    use LWP::UserAgent;


    $cookie_jar = HTTP::Cookies::Netscape->new( 'file' => 'c:/program files/netscape/users/me/cookies.txt');
    $browser->cookie_jar($cookie_jar);


    $ua = LWP::UserAgent->new();


    $req = POST 'http://www.yoursite/login.php', [ login => 'jeff', password => 'test' ];
    $content = $ua->request($req)->as_string;
    print "content: $content
    ";

    but still no go as i cannot identify what my 'cookies.txt' is. i only find the IE6 cookie, not the netscape 7.1, which also tells me it's writing. please help......



  • JonathanJonathan Posts: 2,914Member
    : : : i'm looking to run this simple program ( on a different url - which
    : : : happens to be a login page ). I pass in a valid login & pw, but
    : : : the content is that of the login page, not the page i'm redirected
    : : : to when I submit the same info from a browser. please help..
    : : Hmmm...it may be that you need to pass more than just the login and password. For example, the login button itself and any hidden fields will also need to be passed. Many scripts look for the login button parameter to decide whether this is an attempt to log in or a request for the login page.
    : :
    : : Jonathan
    : :
    : :
    : : ###
    : : for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    : : (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    : : /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");
    : :
    : :
    :
    :
    : i was trying to determine if a cookie was the problem & it does seem to be part of it. with cookies prompted, it does tell me it will write one. the thing now is it writes like 20 .gif files & a couple .js files & a .css file. I found this:
    :
    :
    : use HTTP::Cookies::Netscape;
    : use HTTP::Request::Common qw(POST);
    : use LWP::UserAgent;
    :
    :
    : $cookie_jar = HTTP::Cookies::Netscape->new( 'file' => 'c:/program files/netscape/users/me/cookies.txt');
    : $browser->cookie_jar($cookie_jar);
    :
    :
    : $ua = LWP::UserAgent->new();
    :
    :
    : $req = POST 'http://www.yoursite/login.php', [ login => 'jeff', password => 'test' ];
    : $content = $ua->request($req)->as_string;
    : print "content: $content
    ";
    :
    : but still no go as i cannot identify what my 'cookies.txt' is. i only find the IE6 cookie, not the netscape 7.1, which also tells me it's writing. please help......
    :
    Hmmmm....did you listen to my suggestion or not? I still don't see you trying to feed things like the submit button value as part of your POST request. As for cookies, I think the module you have there reads and writes Netscape cookie files. I don't know the details of what it does, but I don't know it's what you want ot be using either. For any cookies that are returned, you need to look into the returned request object (currently you just dereference it straight to a string and don't hang on to it). See the docs for the module for help with that, or post again. But please do try my suggestion before that.

    Jonathan


    ###
    for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");

Sign In or Register to comment.