473,240 Members | 1,713 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,240 software developers and data experts.

Logging into and parsing a website using Perl


I'm trying to create a perl script that will log into a website (the login
form uses POST), navigate to several pages, and append the (html) content parsed
from those pages to a seperate log file. I'm not very familiar with this aspect
of perl, and have been having some trouble in the POSTing of the form data,
while using cookies to log in.

Visting the site automatically redirects you to a login page. Once you fill
out the login form and click the submit button, you are redirected to the main
site index. The login form uses cookies to establish identity.

I've searched through several google resources, and have built upon what
I've read. I *believe* I am now storing the cookies I come across when loading
the page (using a cookie jar), however, this doesn't seem to be allowing me to
log on to the secure areas of the site. I suspect this is because I am not
properly POSTing the login form data, or otherwise not 'following' the redirect
to the secure area of the site.

At this point in time, I am just trying to get my script to login to the
page (using my appropriate credentials), and then display the site index.

If someone could please offer me some insight and direction into using the
appropriate modules, or else point out any flaws in my code (included below).

------START CODE------

#!/usr/bin/perl -w

use LWP::Simple;
use LWP::UserAgent;

use HTML::TokeParser;
use HTML::Parser;

use HTTP::Request::Common;
use HTTP::Cookies;

use POSIX;

# This is where the log in form is located - once logged in, you are
redirected to the secured content (below).
# This is where the secured content is located. If you aren't logged in, you
are redirected to the above.

$password='My Password';

#----User Agent Config----#
$ua = LWP::UserAgent->new;
$ua->cookie_jar(HTTP::Cookies->new(file => "cookies.txt", autosave => 1,
ignore_discard => 1));
#----/User Agent Config----#

#----Really posting my buttons----#
$content = $ua->request(POST $t_url , [ login_name => $login , password =>
$password , loginSubmit => $submit_value ] );
$ua->request(POST $t_url , [ login_name => $login , password => $password ,
loginSubmit => $submit_value ] );
#----/Really pressing my buttons----#

print "$content";

------END CODE------

As you can tell, I am *trying* to get through to the secure site. However, this
is proving to be somewhat interesting.

I would appreciate any guidance you can offer,

Jul 19 '05 #1
0 11481

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: Ravi Shankar | last post by:
Hi all, I have an enterprise application. I am using Apache Log4J for the logging purposes. WHen a request is received by the application, it goes throug servlets and many classes, and the...
by: Scott | last post by:
I am new to perl, and have not found any good examples of parsing to help me out. I have a text file that I am reading into an array that has to be parsed out and put into another file. I have not...
by: Rotem | last post by:
Hi, while working on something in my current project I have made several improvements to the logging package in Python, two of them are worth mentioning: 1. addition of a logging record field...
by: Chris Smith | last post by:
Hola, pythonisas: The documentation for the logging module is good, but a bit obscure. In particular, there seems to be a lot of action at a distance. The fact that getLogger() can actually be a...
by: Jean-Marie Vaneskahian | last post by:
Reading - Parsing Records From An LDAP LDIF File In .Net? I am in need of a .Net class that will allow for the parsing of a LDAP LDIF file. An LDIF file is the standard format for representing...
by: supern | last post by:
this is my perl script saved as login.pl #!c:/perl/bin/perl.exe $basedir="c:/program files/apache software foundation/apache2.2/cgi-bin"; $datafile="regstr.txt"; $name=$in{'login'};...
by: Jeff | last post by:
ASP.NET 2.0 In my webproject I want to implement some kind of functionality which logs the vistits to the website. I want it to log what pages the user requested, when he arrived at the website...
by: worlman385 | last post by:
I need to parse the following HTML page and extract TV listing data using VC++ http://tvlistings.zap2it.com/tvlistings/ZCGrid.do any good way to extract the data? is easy for VC++ to call...
by: alag20 | last post by:
Hi Guys, Sorry for duplicate posting as this Question refers to both c# and perl cgi script on the net, so please help. Here is the original post...
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.