Re: How do I follow links stored in an array?



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
.



Relevant Pages

  • Re: How to rewrite with awk?
    ... > I'm unfamiliar with tools such as sed & awk. ... Extract the string that matches a RE. ... This script will not only expand all the lines that say "include ... file) and not resetting ARGV(the tmp file), it then lets awk do any ...
    (comp.unix.shell)
  • Re: Function that returns date of file.
    ... string after the date/time when it is used by itself. ... Is that your entire script? ... I make an IF statement that required the 'equals equals'. ... designed database your job will be all that much harder. ...
    (alt.php)
  • Multiple vulnerabilities found in CSGuestbook by CoolSerlets.com
    ... About this script: This is an open source GuestBook script offered by CoolServlets.com ... About the audit: This audit was performed by Daxgrapol and Dopel for RACAT. ... Only the first special character is filtered off of the return string. ... - Buffer overflow is possible (input field length not checked). ...
    (Bugtraq)
  • Re: Script: Remote shutdown of all domain computers
    ... When trying to run the script from a XP workstation, where i am logged in as ... Dim strBase, strFilter, strAttributes, strQuery, objRecordSet ... 2000 or above and allow shutdown, ... Public Function AllComputersAs String() ...
    (microsoft.public.windows.server.scripting)
  • Script: Remote shutdown of all domain computers
    ... I'v searched through the newsgroups for a complete script but to no result. ... I'v also found a script to search trough AD for the computers and added the ... Public Function AllComputersAs String() ... 'Dim sArray() As String ...
    (microsoft.public.windows.server.scripting)