4 Einträge, 1 Seite |
1
2
3
open(EIN, "<test.html") or die("Kann HTML-File nicht oeffnen.\n");
@html = <EIN>;
close(EIN);
<img border="0" src="button1.jpg"><img width="100" border="0" src="button2.jpg">
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#! /usr/bin/perl
use strict;
use warnings;
use HTML::Parser;
my @images;
my $string = qq~<img src="url1">xxxxxxxx <img src="url2">~;
my $p = HTML::Parser->new();
$p->handler(start => \&start_handler,"tagname,attr,self");
$p->parse($string);
print $_,"\n" for(@images);
sub start_handler{
return if(shift ne 'img');
push(@images,shift->{src});
}
1
2
3
4
5
6
while( $str =~ /<img\s+.*?src=(['"])([^\1]+?)\1.*?>/g ) { # matcht Angaben in single und double quotes
print "$2\n";
}
# oder
# my(@treffer) = $str =~ /MUSTER/g;
if (/\<img.*src\=\"(.*)\".*\>/) { print $1, "\n"; }
4 Einträge, 1 Seite |