HTML::Parser se enkrat...
Matej Kovacic
matej.kovacic at uni-lj.si
Mon Apr 23 10:37:53 CEST 2001
Ziv!
Evo, se enkrat imam to vprasanje...
Najprej recem:
#!/usr/bin/perl -w
use HTML::Parser;
use strict;
use diagnostics;
Potem pa:
my $count = 1;
while(<FILE>)
{
my $main_line = $_;
my @line = split(/\t/,$main_line); # delimit the line
my $fullhtml = $line[12];
my @tags; # ce ne dam tegale notri, zajavka da zahteva explicit package...
my $p=HTML::Parser->new(start_h=>[\@tags,"text"],
end_h=>[\@tags,"text"]);
# Parserju povemo, da nas zanimajo tako start (<>) kot end (</>) tagi, in
da
# naj celoten text taga shrani v polje @tags.
$p->parse($fullhtml);
# Elementi @tags so zdaj polja, ki imajo vsako en element, zato moramo
# @tags se "splosciti".
@tags=map($_=$$_[0], at tags);
print "St. vrstice: $count. TAGI: @tags\n";
# potem bi rad prestel vse img tage, vse a href tage, itd... PROBLEM je, da
je polje @tags PRAZNO. $fullhtml je gotovo prava spremenljivka.
$count++;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://liste2.lugos.si/pipermail/lugos-prog/attachments/20010423/043e4389/attachment-0001.html
More information about the lugos-prog
mailing list