Re: How do I follow links stored in an array?
- From: Gunnar Hjalmarsson <noreply@xxxxxxxxx>
- Date: Tue, 29 Apr 2008 18:04:42 +0200
BirgitteRand@xxxxxxxxx wrote:
I don't know how to follow links in an array (@links) at the bottom of
this script.
First you'd better make sure that there are some links in @links to follow.
#jump through tags until you get 'h1'
while( my $title = $p->get_tag( 'h1' )) {
last if $title->[1]->{class} eq 'h1';
}
Since there are no <h1> elements in the document, that code jumps to the end of string.
You can simply do:
$p->get_tag('/h2');
to get to the section of the document you are interested in. No loop needed.
# look through the tokens until you hit the end of 'h1'-----------------------------------------------------^^^^
my @links;
while ( my $token = $p->get_token ) {
last if $token->[0] eq 'E' && $token->[1] eq 'h1';
Suppose you mean 'div' ...
# now follow the links
Yes, but first make sure that @links contains what you expect.
print "$_\n" for @links;
If it does, you can start working with the last section of your script.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
.
- References:
- How do I follow links stored in an array?
- From: BirgitteRand
- How do I follow links stored in an array?
- Prev by Date: Compress::Zlib inflateInit help
- Next by Date: Re: download with HTML::FORM login and password on page
- Previous by thread: How do I follow links stored in an array?
- Next by thread: Re: How do I follow links stored in an array?
- Index(es):
Relevant Pages
|
|