Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Perl Misc (http://www.velocityreviews.com/forums/f67-perl-misc.html)
-   -   automate website login using perl (http://www.velocityreviews.com/forums/t894382-automate-website-login-using-perl.html)

tester 09-23-2005 12:34 PM

automate website login using perl
 
Hi All,

I am trying to automate login to a website using the following code. but
it is not working ... any ideas?
----------------------
use HTTP::Request;
use LWP::UserAgent;

$http_cmd = "http://testertesting:80/login.html";

my %tags = ();
$tags{'action'} = 'calling page/servlet';
$tags{'id'} = 'User';
$tags{'username'} = 'user';
$tags{'password'} = 'passwd';

# Create a user agent object
use LWP::UserAgent;
$ua = LWP::UserAgent->new;
$ua->agent("MyApp/0.1 ");

# Create a request
my $req = HTTP::Request->new(POST => $http_cmd);
$req->content_type('application/x-www-form-urlencoded');
$req->content( %tags );

# Pass request to the user agent and get a response back
my $resp = $ua->request($req);

print $resp->content;
----------------------

~tester

Brian Wakem 09-23-2005 12:38 PM

Re: automate website login using perl
 
tester wrote:

> $http_cmd = "http://testertesting:80/login.html";


> my $req = HTTP::Request->new(POST => $http_cmd);



I doubt you want to post to login.html


> print $resp->content;



And what did it print, login.html?



--
Brian Wakem
Email: http://homepage.ntlworld.com/b.wakem/myemail.png

tester 09-23-2005 12:42 PM

Re: automate website login using perl
 
I am getting "500 read timeout"

Brian Wakem wrote:
> tester wrote:
>
>
>>$http_cmd = "http://testertesting:80/login.html";

>
>
>>my $req = HTTP::Request->new(POST => $http_cmd);

>
>
>
> I doubt you want to post to login.html
>
>
>
>>print $resp->content;

>
>
>
> And what did it print, login.html?
>
>
>


Brian Wakem 09-23-2005 12:47 PM

Re: automate website login using perl
 
tester wrote:

> I am getting "500 read timeout"



Don't top post.

Then your script is fine. Either you are POSTing to the wrong address or
the target server is misconfigured.



--
Brian Wakem
Email: http://homepage.ntlworld.com/b.wakem/myemail.png

tester 09-23-2005 01:09 PM

Re: automate website login using perl
 
Hi Brian,
I don't understand "Don't top post"? :-(

I wonder whether POST takes the form page url or the target page url
(login credentials verification page)!
If I give the form page url then I am getting page content as output
If I give the target page url then I am getting "500 read timeout"

Thankyou,
tester

Brian Wakem wrote:
> tester wrote:
>
>
>>I am getting "500 read timeout"

>
>
>
> Don't top post.
>
> Then your script is fine. Either you are POSTing to the wrong address or
> the target server is misconfigured.
>
>
>


Paul Lalli 09-23-2005 01:20 PM

Re: automate website login using perl
 
tester wrote:
> Hi Brian,
> I don't understand "Don't top post"? :-(


Have you considered asking Google what it means, before posting again?
You obviously have figured out you're doing *something* wrong, but
rather than attempt to figure out what it was, you just went ahead and
posted again, following the same style you have been. How can that not
be considered rude?

When I type "top post" into the Google homepage, I get this as the
first result:
http://catb.org/~esr/jargon/html/T/t...t.html&e=10342

Paul Lalli


Brian Wakem 09-23-2005 01:27 PM

Re: automate website login using perl
 
tester wrote:

> Hi Brian,
> I don't understand "Don't top post"? :-(
>
> I wonder whether POST takes the form page url or the target page url
> (login credentials verification page)!
> If I give the form page url then I am getting page content as output
> If I give the target page url then I am getting "500 read timeout"



It's the target url, so my all of my previous answer still applies.


--
Brian Wakem
Email: http://homepage.ntlworld.com/b.wakem/myemail.png

Richard Gration 09-23-2005 01:45 PM

Re: automate website login using perl
 
On Fri, 23 Sep 2005 18:04:15 +0530, tester wrote:

> Hi All,
>
> I am trying to automate login to a website using the following code. but
> it is not working ... any ideas?


Once you do have it working, you will almost certainly need a cookie jar
(instructions for the use of which you will find in the LWP docs). This is
because web sites typically use a cookie for persistent logins.

Rich

pdc 09-23-2005 08:19 PM

Re: automate website login using perl
 
Paul Lalli,
I guess you either do not work in customer service, or don't care about
others' feelings when they ask for help. Accusing someone of being rude
simply because they don't adhere to the same grammatical rules as you seems
a bit harsh.
As for the advice to google everything one does not understand; Let's all
stop using newsgroups and stop asking anyone else for help -- all the
information is available through google surely?

As for top posting, When people regularly quote entire passages in their
posts, I actually prefer to see the latest text at the top of the list.

<quoted text snipped out of courtesy>



A. Sinan Unur 09-24-2005 12:08 AM

Re: automate website login using perl
 
"pdc" <pdc@cdp.moc> wrote in
news:hrZYe.11967$0u2.2536037@news20.bellglobal.com :

> Paul Lalli,
> I guess you either do not work in customer service,


There are no customers here.

There is a difference between being a paying customer, and asking for
others to donate their time.

....

> As for top posting, When people regularly quote entire passages in
> their posts, I actually prefer to see the latest text at the top of
> the list.


The recommendation is to quote an appropriate amount of context so your
post stands on its own.

The justification for this recommendation can be found in the
guidelines.

I think, it this case, the OP got confused between 'post' as in posting
to a newsgroup and HTTP POST when reading Brian Wakem's response. He
could have used Google to understand the diffence:

http://www.google.com/search?q=top+posting

Sinan

PS: *PLONK*

--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(reverse each component and remove .invalid for email address)

comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/cl...uidelines.html


All times are GMT. The time now is 06:48 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.