D
DVH
Hi,
I'm trying to get tokeparser to fetch a series of hyperlinks and print the
URL followed by the link text.
The following script ("eurofeed.pl") gives me "Can't coerce array into hash
at eurofeed.pl line 31"
Line 31 is "if ($tag->[2]{class} and $tag->[2]{class} eq 'docSel-titleLink')
{"
The HTML looks like this:
=======================================
<td colspan="2"> </td>
<td align="left" colspan="3">
<a title="" class="docSel-titleLink"
href="pressReleasesAction.do?reference=EPSO/05/06">
My link text here
</a>
</td>
</tr>
---------------------------------------------
My script looks like this:
#!/usr/bin/perl -w
use strict;
use LWP::Simple;
use HTML::TokeParser;
use XML::RSS;
my $content =
et( "http://europa.eu.int/rapid/recentPressReleasesAction.do?guiLanguage=en&
hits=500" ) or die $!;
my $stream = HTML::TokeParser->new( \$content ) or die $!;
my ($tag, $headline, $url);
while ( $tag = $stream->get_tag("a") ) {
if ($tag->[2]{class} and $tag->[2]{class} eq 'docSel-titleLink') {
$url = $tag->[2]{href} || "--";
$headline = $stream->get_trimmed_text('/a')
print $url
print $headline
I'm trying to get tokeparser to fetch a series of hyperlinks and print the
URL followed by the link text.
The following script ("eurofeed.pl") gives me "Can't coerce array into hash
at eurofeed.pl line 31"
Line 31 is "if ($tag->[2]{class} and $tag->[2]{class} eq 'docSel-titleLink')
{"
The HTML looks like this:
=======================================
<td colspan="2"> </td>
<td align="left" colspan="3">
<a title="" class="docSel-titleLink"
href="pressReleasesAction.do?reference=EPSO/05/06">
My link text here
</a>
</td>
</tr>
---------------------------------------------
My script looks like this:
#!/usr/bin/perl -w
use strict;
use LWP::Simple;
use HTML::TokeParser;
use XML::RSS;
my $content =
et( "http://europa.eu.int/rapid/recentPressReleasesAction.do?guiLanguage=en&
hits=500" ) or die $!;
my $stream = HTML::TokeParser->new( \$content ) or die $!;
my ($tag, $headline, $url);
while ( $tag = $stream->get_tag("a") ) {
if ($tag->[2]{class} and $tag->[2]{class} eq 'docSel-titleLink') {
$url = $tag->[2]{href} || "--";
$headline = $stream->get_trimmed_text('/a')
print $url
print $headline