develooper Front page | perl.beginners | Postings from November 2003

Re: automate web login

Thread Previous
From:
Wiggins d'Anconia
Date:
November 24, 2003 16:52
Subject:
Re: automate web login
Message ID:
3FC2A56D.8070501@danconia.org
Please bottom post, and always group reply so others can help and be 
helped....

David Byrne wrote:
> Dear Wiggins,
> 
> Thank you for your reply.  It is true that the /login
> resolves the '405' error, but the updated script
> doesn't seem to log me in; instead I remain at the
> login page.  If I try to GET another URL within the
> site, I get '403 Forbidden'.
> 
>>From that URL, upon login, I should be redirected to
> http://www.gene-regulation.com/index.html where I can
> GET to any other URL.
> 

I am not terribly familar with using the cookie jar, you don't do any 
error checking of setting the file, etc. That would be the first place I 
would look, I assume you know that the site utilizes cookies for 
authentication purposes? I also didn't see specifically a URL to test 
with that was "protected" (though I only made a cursory glance) and 
didn't login with your account assuming that username and password isn't 
spoofed. Double check your URLs, etc.

Any one else have some thoughts?

http://danconia.org

> 
> --- Wiggins d Anconia <wiggins@danconia.org> wrote:
> 
>>
>>>Greetings,
>>>
>>>I used CPAN (libwww-perl) docs as my main
>>
>>reference
>>
>>>and generated the following script (trying
>>
>>'content'
>>
>>>as well as 'authorization_basic' for user id &
>>
>>pw),
>>
>>>but keep getting "405 Method Not Allowed".
>>>
>>
>>'Method not allowed' is usually provided when you
>>try a POST and need a
>>GET or vice versa, however, in this case I believe
>>you are getting that
>>because you are not POST'ing to the login url, but
>>to the home page
>>instead. See below...
>>
>>
>>>I would very much appreciate any suggestions.
>>>
>>>Cheers,
>>>David
>>>
>>>#!perl -w
>>>use LWP::UserAgent;
>>>use HTTP::Cookies;
>>>
>>>$ua = LWP::UserAgent->new;
>>>$ua->cookie_jar(HTTP::Cookies->new(file =>
>>>"lwpcookies.txt", autosave => 1));
>>>
>>># Create a request
>>>my $req = HTTP::Request->new(POST =>
>>>'http://www.gene-regulation.com/');
>>
>>The above needs a 'login' tacked onto the end so you
>>are submitting your
>>content to the actual login script not to the
>>homepage.
>>
>>
> $req->content_type('application/x-www-form-urlencoded');
> 
>>># Login
>>># $req->content('user=gratner&password=motley');
>>
>>The above should be what you need.
>>
>>Does that get it?
>>
>>http://danconia.org
>


Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About