F
Francis Sylvester
Hi,
I'm a Perl newbie and am having a nightmare trying to get the code below
working. I'm trying to fetch a webpage and if a link within the page matches
the search criterion - return the text after the link. It doesn't seem to be
working and I'm wondering if it's because the pattern match is within the
while loop. If anybody can shed some light I'd be eternally grateful!
Cheers,
Francis
# --------------------------
use LWP::Simple;
use HTML::TokeParser;
my $document = get("http://www.anexamplesite.com");
my $mymatch = "searchstring";
my $parser = HTML::TokeParser->new(\$document);
while ($token = $parser->get_tag("a")) {
if ($token->[1]->{"href"} =~ /$mymatch/) {
# print $server.$token->[1]->{href}."\n";
$document =~ /$searchstring(.+?)someidentifier/;
print "$1";
}
}
I'm a Perl newbie and am having a nightmare trying to get the code below
working. I'm trying to fetch a webpage and if a link within the page matches
the search criterion - return the text after the link. It doesn't seem to be
working and I'm wondering if it's because the pattern match is within the
while loop. If anybody can shed some light I'd be eternally grateful!
Cheers,
Francis
# --------------------------
use LWP::Simple;
use HTML::TokeParser;
my $document = get("http://www.anexamplesite.com");
my $mymatch = "searchstring";
my $parser = HTML::TokeParser->new(\$document);
while ($token = $parser->get_tag("a")) {
if ($token->[1]->{"href"} =~ /$mymatch/) {
# print $server.$token->[1]->{href}."\n";
$document =~ /$searchstring(.+?)someidentifier/;
print "$1";
}
}