For Programmers: Free Programming Magazines  


Home > Archive > PERL Modules > January 2006 > login to National Post using LWP









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author login to National Post using LWP
Ed Cheng

2006-01-10, 4:00 am

Hi,

I want to download the National Post to my computer using LWP. There are
five input fields in their login page (URL:
https://members.canada.com/login.as...st%2findex.html )
:

<input type="hidden" name="__VIEWSTATE" value="dDwxN ... Y" />
<input name="email_address" type="text" id="email_address" class="textbox"
/>
<input name="password" type="password" id="password" class="textbox" />
<input id="chkRemember" type="checkbox" name="chkRemember" />
<input type="image" name="ibtnLogin" id="ibtnLogin" class="submitbutton"
src="cc/images/buttons/en_submit_FFFFFF.gif" alt="submit" border="0" />

The value of hidden field __VIEWSTATE is very long, more than 1900
characters.

So I write a little Perl program:

my
$url='https://members.canada.com/login.aspx?site=cc&provider=canada&brand=na
tionalpost&ReturnUrl=http%3a%2f%2fwww.canada.com%2fnationalpost%2findex.html
';
my $req = POST $url, [ __VIEWSTATE => 'dDwxN ...Y', email_address => 'valid
email address', password => 'valid login password', chkRemember => ' ',
ibtnLogin => ' ' ];
my $res=$ua->request($req,'c:\NPlogin.html');

But it cannot login with error 500 Internal Server Error.

There must be something to do with the input fields, __VIEWSTATE and
ibtnLogin.

Please help.

Cheers,
Ed


DJ Stunks

2006-01-10, 4:00 am

Ed Cheng wrote:
> Hi,
>
> I want to download the National Post to my computer using LWP.


VIEWSTATE (or some other field) may be time-sensitive and/or there may
be any number of cookies exchanged.

Use LiveHTTPHeaders to watch your normal login, then try to mimic it.

-jp

Peter Scott

2006-01-10, 4:00 am

On Wed, 04 Jan 2006 22:20:05 -0800, DJ Stunks wrote:
> Ed Cheng wrote:
>
> VIEWSTATE (or some other field) may be time-sensitive and/or there may
> be any number of cookies exchanged.
>
> Use LiveHTTPHeaders to watch your normal login, then try to mimic it.


Or use WWW::Mechanize to start from the entry page and not have to worry
about any hidden fields or cookies.

--
Peter Scott
http://www.perlmedic.com/
http://www.perldebugged.com/

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com