Leser: 19
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
#!/usr/bin/perl use strict; use warnings; use WWW::Mechanize; open(DESC, ">> desc"); my $mech = WWW::Mechanize->new(); $mech->stack_depth(0); $mech->get( 'http://epicute.icanhascheezburger.com/', ':content-file' => 'epicute.html' ); open(FILE, '< epicute.html'); my $document = ''; while (<FILE>) { $document .= $_; } foreach my $match ($document =~ m!<textarea[^>]+><a href="([^"]+)"><img src='([^']+)' title="cute food photos - (.+?)".+?</textarea>!g) { print DESC $1 . "\t" . $2 . "\t" . $3 ."\n"; } close(FILE); close(DESC);
http://epicute.icanhascheezburger.com/2010/10/28/cute-food-photos-mini-candy-apple-donuts/ http://epicute.files.wordpress.com/2010/10/aa160626-34e8-4d31-b4ce-2b0d10f6c875.jpg Mini Candy &quot;Apple&quot; Donuts
1 2 3 4
my $text = "Peter Pan geht sehr gerne in den Park"; foreach ($text =~ /(P\w+)/) { print "$1\n"; }
1 2 3 4
my $text = "Peter Pan geht sehr gerne in den Park"; while ($text =~ /(P\w+)/g) { print "$1\n"; }
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 use strict; use warnings; use LWP::Simple; use HTML::TreeBuilder; use Data::Dumper; my $html = HTML::TreeBuilder->new(); my $html_data=LWP::Simple::get('http://epicute.icanhascheezburger.com/'); my @data; my @images; if($html_data) { $html->parse($html_data); # nach dem Textarea suchen: for my $tag ( $html->look_down( _tag => 'textarea' ) ) { next if(!$tag->attr('name') || $tag->attr('name') ne 'easyshare2' ); push(@data,$tag->content()->[0]); } } print Dumper(\@data);