Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > automate website login using perl

Reply
Thread Tools

automate website login using perl

 
 
tester
Guest
Posts: n/a
 
      09-23-2005
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
 
Reply With Quote
 
 
 
 
Brian Wakem
Guest
Posts: n/a
 
      09-23-2005
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
 
Reply With Quote
 
 
 
 
tester
Guest
Posts: n/a
 
      09-23-2005
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?
>
>
>

 
Reply With Quote
 
Brian Wakem
Guest
Posts: n/a
 
      09-23-2005
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
 
Reply With Quote
 
tester
Guest
Posts: n/a
 
      09-23-2005
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.
>
>
>

 
Reply With Quote
 
Paul Lalli
Guest
Posts: n/a
 
      09-23-2005
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

 
Reply With Quote
 
Brian Wakem
Guest
Posts: n/a
 
      09-23-2005
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
 
Reply With Quote
 
Richard Gration
Guest
Posts: n/a
 
      09-23-2005
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
 
Reply With Quote
 
pdc
Guest
Posts: n/a
 
      09-23-2005
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>


 
Reply With Quote
 
A. Sinan Unur
Guest
Posts: n/a
 
      09-24-2005
"pdc" <(E-Mail Removed)> wrote in
news:hrZYe.11967$(E-Mail Removed) :

> 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 <(E-Mail Removed)>
(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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there any way to automate the test of an applet using perl? lofenee Perl Misc 5 07-15-2008 02:56 AM
how to automate installation of a MSI file using perl king Perl Misc 2 11-16-2006 09:20 AM
automate command line script using perl perlperl Perl Misc 6 06-16-2006 03:38 PM
automate file upload using perl [nix] Perl Misc 1 09-07-2003 06:41 PM
automate file upload using perl [nix] Perl 1 09-07-2003 06:33 PM



Advertisments