Hallo All,
I tried to solve my problem using HTML::SimpleLinkExtor and
HTML::LinkExtor.In both cases I got a similar error message.
my scrpit is as follows:
#!/usr/bin/perl -w
use strict;
use HTML::TreeBuilder; #Parser that builds HTML
syntax
tree
use HTTP::Request::Form; #Construct HTTP::Request
objects for
Form
processing
use HTML::Parse;
use HTTP::Request::Common; #Construct common HTTP::Request
objects
use LWP::UserAgent; #Provides an object for
clients,
UserAgent object acts as a
browser
use LWP::Simple;
use URI::URL;
use HTML::SimpleLinkExtor; #Module to extract Links
use Data::Dumper;
use HTTP::Headers;
# Upload the Website
my $url = url 'http://some_host/navitune.html';
my $ua = new LWP::UserAgent; # Create a
LWP::UserAgent
object
$ua->requests_redirectable ( ['POST'] ); # Add METHOD POST for
redirection
my $res = $ua->request(POST $url);
# Parse the website and extract the Form
my $tree = new HTML::TreeBuilder->parse( $res->content);
$tree->eof(); #Signals
that
you are finished with parsing content into
the tree
my @forms = @{ $tree->extract_links('FORM') };
# The first Form
my $f = HTTP::Request::Form->new( $forms[0][1], $url ); #Constructs a
new
form processor
#$f->dump(); # Prints the extrachted Form on the STDOUT
# Fill and Send the Form
$f->field( 'wav_file', 'st11.wav' ); # retrieves or sets a
field-value ,
where the fieldname =wav_file
,fieldvalue
= st11.wav, which is also the file to be
Uploaded
my $response = HTTP::Response->new;
$response = $ua->request($f->press('submit')); # Practically it clicks
the
Submit button and the form is
sent.
# Response from the Serverside
$response->as_string(); #as_string is a method of
HTTP::Request.It
returns the text version of the request
object
as a string with \n placed after each
line.
# Parse the website and extrach the first three Links using
HTML::LinkExtor
my $linkparser = HTML::SimpleLinkExtor->new(); #Create
SimpleLinkExtor
object
$linkparser->parse($response); #Parse
response
my @all_links = $linkparser->links; #Gets a list
if links
print Dumper \@all_links; #Print list of links out
when i execute this script, I get this: $VAR1 = [ ];
I donot have much experience in perl programming, so i cannot figure out the
mistake or am I doing some mistake in my scrpit ?
I would be thankful if somebody could invest time to answer my question.
thanks in advance
nandita
Nandita Shenvi
Appartment Nr. 707
Westhoffstr. 15
44791 Bochum
Germany
0234/5844456
_________________________________________________________________
Add photos to your e-mail with MSN 8. Get 2 months FREE*.
http://join.msn.com/?page=features/featuredemail
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
- Re: HTML::SimpleLinkExtor Nandita Shenvi
- Re: HTML::SimpleLinkExtor Rob Dixon
- Re: HTML::SimpleLinkExtor Rob Dixon