also you'll find page two interesting for posting your passing your tracking number:
http://www.perl.com/pub/a/
Main Topics
Browse All TopicsI am trying to write a Perl program to access tracking information from a website on shipped packages. One difference is that with this site, I need to authenticate with a userid and password first in a screen, then enter a reference number to retrieve the information required.
I have been looking around/reading stuff online for using LWP or Mechanize etc. No success yet. Can someone help me out please. I need to get this completed very quickly. So, please help me out in a timely manner on this one. Here are the steps:
1) Need to pass the user id and password Login into the site.
2) And, in the next form, need to pass the tracking number to retrieve details.
Thanks in advance for help.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
also you'll find page two interesting for posting your passing your tracking number:
http://www.perl.com/pub/a/
Hello, I tried the POST commands to access the login page first. The field names are hidden. So, I am not sure how to pass value to submit the form. Here is how the "View Source" looks:
<form name="FormTrack" method="post" action="tracking.aspx" id="FormTrack">
<input type="hidden" name="__EVENTTARGET" value="" />
<input type="hidden" name="__EVENTARGUEMENT" value="" />
<input type="hidden" name="__VIEWSTATE" value="dDW................
And, here is the code I am trying:
#!D:\perl\bin\perl.exe
use LWP;
use HTTP::Request::Common;
$ua = LWP::UserAgent->new;
$req=$ua->request(POST 'URL',
["__EVENTTARGET" => "userid", "__EVENTARGUEMENT" => "password", "__VIEWSTATE" => "btnSubmit"]);
print $req->content;
The following is the output from the program:
--------------------------
<html><head><title>Object moved</title></head><body>
<h2>Object moved to <a href='/Error.aspx?aspxerro
</body></html>
--------------------------
Please help!
Mathav
Hi mathavra,
you dont seem to be using the credentials method, is this correct. ie you dont need to login first and the acess a page?
CHANGE POST to post
my $req=$ua->request(post 'URL',
["__EVENTTARGET" => "userid", "__EVENTARGUEMENT" => "password", "__VIEWSTATE" => "btnSubmit"]);
also have you added the error handling?
die "$url error: ", $response->status_line
unless $response->is_success;
die "Weird content type at $url -- ", $response->content_type
unless $response->content_type eq 'text/html';
Does the credentials method work for the hidden fields?? Also, when I added the error lines I get the following error:
"302 Found at p1_ats_l.pl line 10.".
Also, I have to use POST in uppercase since I am trying in a Windows 2000 platform.
I am going to try the credentials now.
Thanks for the comments
Mathav
> .. how to pass values to hidden fields
use CGI;
my $q=new CGI;
print $q->hidden("par_name","par
> .. also trace out the hidden fields?
what do you mean by that?
as explained above, the server can't destinguish if a parameter was a hidden field or not according the raw request data. But as the server (in particular the application on it) is the same for generating the page with the hidden fields and then receiving the request, it already "knows" which parameters have been hidden ;-)
Business Accounts
Answer for Membership
by: PeeweePosted on 2005-06-03 at 02:15:43ID: 14137841
Hi mathavra,
2002/08/20 /perlandlw p.html?pag e=4 2002/08/20 /perlandlw p.html?pag e=5
actually what you talk about is covered in the links below using LWP. To get around the username & password problem u need to set the credentials of the browser.
http://www.perl.com/pub/a/
http://www.perl.com/pub/a/
regards Peewee