|< 1 2 >| | 13 Einträge, 2 Seiten |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use HTML::LinkExtor;
$parser = HTML::LinkExtor->new(undef, $base_url);
$parser->parse_file($filename);
@links = $parser->links;
foreach $linkarray (@links) {
my @element = @$linkarray;
my $elt_type = shift @element; # element type
# possibly test whether this is an element we're interested in
while (@element) {
# extract the next attribute and its value
my ($attr_name, $attr_value) = splice(@element, 0, 2);
# ... do something with them ...
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/perl -w
use CGI::Carp "fatalsToBrowser";
use HTML::LinkExtor;
$filename = "index.html";
$parser = HTML::LinkExtor->new(undef, $base_url);
$parser->parse_file($filename);
@links = $parser->links;
foreach $linkarray (@links) {
my @element = @$linkarray;
my $elt_type = shift @element; # element type
# possibly test whether this is an element we're interested in
while (@element) {
# extract the next attribute and its value
my ($attr_name, $attr_value) = splice(@element, 0, 2);
# ... do something with them ...
}
}
print "Content-Type: text/html\n\n";
print $attr_name;
print $attr_value;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#! /usr/bin/perl
use strict;
use warnings;
use CGI;
use CGI::Carp qw(fatalsToBrowser warningsToBrowser);
use HTML::LinkExtor;
my $url = "http://www.perl-community.de/index.shtml";
# neues cgi-objekt erstellen
my $cgi = CGI->new();
print $cgi->header(); # gibt http-header aus
print $cgi->start_html(); # gibt <html>... aus
# webseite laden und parsen
my $parser = HTML::LinkExtor->new(undef, $url);
$parser->parse_file($filename);
my @links = $parser->links;
foreach $linkarray (@links) {
my ($eltType, @element) = @$linkarray;
# possibly test whether this is an element we're interested in
while (@element) {
# extract the next attribute and its value
my ($attr_name, $attr_value) = splice(@element, 0, 2);
# mach was mit $attr_name und $attr_value, z.b.
print "$eltType: $attr_name => $attr_value <br>\n";
} # while
} # foreach
# </body></html> ausgeben
print $cgi->end_html();
|< 1 2 >| | 13 Einträge, 2 Seiten |