automate website login using perl

T

tester

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;
 
B

Brian Wakem

tester said:
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.
 
T

tester

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
 
P

Paul Lalli

tester said:
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/top-post.html&e=10342

Paul Lalli
 
B

Brian Wakem

tester said:
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.
 
R

Richard Gration

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
 
P

pdc

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

A. Sinan Unur

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*
 
P

Paul Lalli

pdc said:
Paul Lalli,
I guess you either do not work in customer service,

I am not working here. Are you paying me? I'm donating my time and
knowledge. What I ask in return is not a paycheck, but that those
requesting assistance follow a few simple requests and make an attempt
to solve their problems on their own.
or don't care about others' feelings when they ask for help.

100% correct. I am not a shrink. I am not here to make anyone feel
good about him/herself. If you have a question about Perl, and I am
able to assist, I will be happy to do so. Your emotional and
psychological state is wholly irrelevant to me.
Accusing someone of being rude
simply because they don't adhere to the same grammatical rules as you seems
a bit harsh.

I have no idea what you're talking about. No where in this thread (or
any other I can remember off hand), did I ever mention anyone's grammar
or lack there of.
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?

Stop asking the newsgroup? Absolutely not. Attempting to find the
information on one's own before wasting the time of hundreds of people
around the world? Damn right.
As for top posting, When people regularly quote entire passages in their
posts,

People should *not* be quoting entire passages in their post. They
should be trimming it down to a relevant amount of material. Have you
read the Posting Guidelines?
I actually prefer to see the latest text at the top of the list.

Well congratulations, but the vast majority of people who frequent this
group - the ones actually offering our time, assistance, and knowledge,
rather than requesting it of others - prefer a different style. When
people are asking for free assistance, I don't think it's out of line
to request that they follow that style.
<quoted text snipped out of courtesy>

Single most ironic statement I've seen in this group in at least 2
months. It is courteous to not follow the standard traditions and
customs of the people who've been in this group several magnitudes of
time longer than you? You need a better dictionary.

Paul Lalli
 
T

Tad McClellan

pdc said:
Paul Lalli,
I guess you either do not work in customer service,


That is not relevant, since Usenet is not a help-desk.

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.


You seem to have missed the point of Paul's post, since it was not
about grammatical rules. It was Brian's post that pointed out the
grammatical rules preferred here.

Paul's post was about asking hundreds (thousands?) of people around
the world a question that is easily answered without taking up
those volunteers time. (and thereby drawing them away from helping
others who have a not-easily-found answer.)

He then went on to provide the additional "customer service" of
teaching how this question could have been answered more quickly
and efficiently.

Learning the approach he suggested will help answer not only _this_
question, but many future questions as well.

He taught the OP how to fish rather than simply giving him a fish.

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?


You are being disingenuous there, as we do not object to _all_ questions.

We do, however, object to answering questions whose answer is
easily answered in a standard place, such as the docs or a
Usenet archive.

We are not a "look it up for me" service, we are a "help me because
I've looked for the answer, but could not find it" service.

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.


That's nice, but also irrelevant, since a properly quoted followup
does not meet your "entire" predicate.

A properly quoted followup would have included only enough of a
passage to indicate the context for the comment that is to follow.
 
P

pdc

I do apologise if I caused offence. It was an admittedly rash reaction to
what I read as a disparaging response to a reader's request for assistance.
I did not fully understand the general attitude of the many respondants to
this group.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top